-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvecscale.m
50 lines (47 loc) · 1.03 KB
/
vecscale.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function ss = vecscale(vector)
%
% Function Name:
%
% vecscale - Transformation matrix for a scaling.
%
% Calling Sequence:
%
% ss = vecscale(svec)
%
% Parameters:
%
% svec : A vectors defining the scaling along the x,y and z axes.
% i.e. [sx, sy, sy]
%
% ss : Scaling Transformation Matrix
%
% Description:
%
% Returns a (4x4) Transformation matrix for scaling.
%
% The matrix is:
%
% [ sx 0 0 0]
% [ 0 sy 0 0]
% [ 0 0 sz 0]
% [ 0 0 0 1]
%
% Example:
%
% Scale up the NURBS line (0.0,0.0,0.0) - (1.0,1.0,1.0) by 3 along
% the x-axis, 2 along the y-axis and 4 along the z-axis.
%
% line = nrbline([0.0 0.0 0.0],[1.0 1.0 1.0]);
% trans = vecscale([3.0 2.0 4.0]);
% sline = nrbtform(line, trans);
%
% See:
%
% nrbtform
% Dr D.M. Spink
% Copyright (c) 2000.
if nargin < 1
error('Scaling vector not specified');
end
s = [vector(:);0;0];
ss = [s(1) 0 0 0; 0 s(2) 0 0; 0 0 s(3) 0; 0 0 0 1];