-
Notifications
You must be signed in to change notification settings - Fork 2
/
nrbtform.m
53 lines (50 loc) · 1.38 KB
/
nrbtform.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
51
52
53
function nurbs = nrbtform(nurbs,tmat)
%
% Function Name:
%
% nrbtform - Apply transformation matrix to the NURBS.
%
% Calling Sequence:
%
% tnurbs = nrbtform(nurbs,tmatrix);
%
% Parameters:
%
% nurbs : NURBS data structure (see nrbmak for details).
%
% tmatrix : Transformation matrix, a matrix of size (4,4) defining
% a single or multiple transformations.
%
% tnurbs : The return transformed NURBS data structure.
%
% Description:
%
% The NURBS is transform as defined a transformation matrix of size (4,4),
% such as a rotation, translation or change in scale. The transformation
% matrix can define a single transformation or multiple series of
% transformations. The matrix can be simple constructed by the functions
% vecscale, vectrans, vecrotx, vecroty, and vecrotz.
%
% Examples:
%
% Rotate a square by 45 degrees about the z axis.
%
% rsqr = nrbtform(nrbrect(), vecrotz(deg2rad(45)));
% nrbplot(rsqr, 10);
%
% See:
%
% vecscale, vectrans, vecrotx, vecroty, vecrotz
% D.M. Spink
% Copyright (c) 2000
if nargin < 2
error('Not enough input arguments!');
end;
if iscell(nurbs.knots)
% NURBS is a surface
[dim,nu,nv] = size(nurbs.coefs);
nurbs.coefs = reshape(tmat*reshape(nurbs.coefs,dim,nu*nv),[dim nu nv]);
else
% NURBS is a curve
nurbs.coefs = tmat*nurbs.coefs;
end