]> Creatis software - CreaPhase.git/blob - octave_packages/nurbs-1.3.6/vecscale.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nurbs-1.3.6 / vecscale.m
1 function ss = vecscale(vector)
2
3 %
4 % VECSCALE: Transformation matrix for a scaling.
5
6 % Calling Sequence:
7
8 %   ss = vecscale(svec)
9
10 % INPUT:
11
12 %   svec    : A vectors defining the scaling along the x,y and z axes.
13 %             i.e. [sx, sy, sy]
14 %
15 % OUTPUT:
16
17 %   ss      : Scaling Transformation Matrix
18
19 % Description:
20
21 %   Returns a (4x4) Transformation matrix for scaling.
22
23 %   The matrix is:
24
25 %         [ sx  0   0   0]
26 %         [ 0   sy  0   0]
27 %         [ 0   0   sz  0]
28 %         [ 0   0   0   1]
29
30 % Example:
31
32 %   Scale up the NURBS line (0.0,0.0,0.0) - (1.0,1.0,1.0) by 3 along
33 %   the x-axis, 2 along the y-axis and 4 along the z-axis.
34
35 %   line = nrbline([0.0 0.0 0.0],[1.0 1.0 1.0]);
36 %   trans = vecscale([3.0 2.0 4.0]);
37 %   sline = nrbtform(line, trans);
38
39 % See also:
40
41 %    nrbtform
42 %
43 %    Copyright (C) 2000 Mark Spink, 2007 Daniel Claxton
44 %
45 %    This program is free software: you can redistribute it and/or modify
46 %    it under the terms of the GNU General Public License as published by
47 %    the Free Software Foundation, either version 2 of the License, or
48 %    (at your option) any later version.
49
50 %    This program is distributed in the hope that it will be useful,
51 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
52 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
53 %    GNU General Public License for more details.
54 %
55 %    You should have received a copy of the GNU General Public License
56 %    along with this program.  If not, see <http://www.gnu.org/licenses/>.
57
58 if nargin < 1
59   error('Scaling vector not specified');
60 end   
61
62 s = [vector(:);0;0];
63 ss = [s(1) 0 0 0; 0 s(2) 0 0; 0 0 s(3) 0; 0 0 0 1];
64
65 end