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