-
Notifications
You must be signed in to change notification settings - Fork 2
/
nrbdeval.m
71 lines (58 loc) · 1.62 KB
/
nrbdeval.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function [pnt,jac] = nrbdeval(nurbs, dnurbs, tt)
% Evaluation of the derivative NURBS curve or surface.
%
% [pnt, jac] = nrbdeval(crv, dcrv, tt)
% [pnt, jac] = nrbdeval(srf, dsrf, {tu tv})
%
% INPUTS:
%
% crv - original NURBS curve.
%
% srf - original NUBRS surface
%
% dcrv - NURBS derivative represention of crv
%
% dsrf - NURBS derivative represention of surface
%
% tt - parametric evaluation points
% If the nurbs is a surface then tt is a cell
% {tu, tv} are the parametric coordinates
%
% pnt - evaluated points.
% jac - evaluated first derivatives (Jacobian).
%
% Examples:
%
% // Determine the first derivatives a NURBS curve at 9 points for 0.0 to
% // 1.0
% tt = linspace(0.0, 1.0, 9);
% dcrv = nrbderiv(crv);
% [pnts,jac] = nrbdeval(crv, dcrv, tt);
% D.M. Spink
% Copyright (c) 2000.
if ~isstruct(nurbs)
error('NURBS representation is not structure!');
end
if ~strcmp(nurbs.form,'B-NURBS')
error('Not a recognised NURBS representation');
end
[cp,cw] = nrbeval(nurbs, tt);
if iscell(nurbs.knots)
% NURBS structure represents a surface
temp = cw(ones(3,1),:,:);
pnt = cp./temp;
[cup,cuw] = nrbeval(dnurbs{1}, tt);
tempu = cuw(ones(3,1),:,:);
jac{1} = (cup-tempu.*pnt)./temp;
[cvp,cvw] = nrbeval(dnurbs{2}, tt);
tempv = cvw(ones(3,1),:,:);
jac{2} = (cvp-tempv.*pnt)./temp;
else
% NURBS is a curve
temp = cw(ones(3,1),:);
pnt = cp./temp;
% first derivative
[cup,cuw] = nrbeval(dnurbs,tt);
temp1 = cuw(ones(3,1),:);
jac = (cup-temp1.*pnt)./temp;
end