1 function ck = curvederiveval (n, p, U, P, u, d)
3 % CURVEDERIVEVAL: Compute the derivatives of a B-spline curve.
5 % usage: ck = curvederiveval (n, p, U, P, u, d)
9 % n+1 = number of control points
13 % u = evaluation point
14 % d = derivative order
18 % ck (k+1) = curve differentiated k times
20 % Adaptation of algorithm A3.4 from the NURBS book, pg99
22 % Copyright (C) 2009 Carlo de Falco
23 % Copyright (C) 2010 Rafael Vazquez
25 % This program is free software: you can redistribute it and/or modify
26 % it under the terms of the GNU General Public License as published by
27 % the Free Software Foundation, either version 2 of the License, or
28 % (at your option) any later version.
30 % This program is distributed in the hope that it will be useful,
31 % but WITHOUT ANY WARRANTY; without even the implied warranty of
32 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 % GNU General Public License for more details.
35 % You should have received a copy of the GNU General Public License
36 % along with this program. If not, see <http://www.gnu.org/licenses/>.
41 span = findspan (n, p, u, U);
43 N(1:ip+1,ip+1) = basisfun (span, u, ip, U)';
46 pk = curvederivcpts (n, p, U, P, du, span-p, span);
50 ck(k+1) = ck(k+1) + N(j+1,p-k+1)*pk(k+1,j+1);
58 %! coefs(:,1) = [0;0;0;1];
59 %! coefs(:,2) = [1;0;1;1];
60 %! coefs(:,3) = [1;1;1;1];
61 %! crv = nrbmak (coefs, k);
62 %! ck = curvederiveval (crv.number-1, crv.order-1, crv.knots, squeeze (crv.coefs(1,:,:)), 0.5, 2);
63 %! assert(ck, [0.75; 1; -2]);
64 %! ck = curvederiveval (crv.number-1, crv.order-1, crv.knots, squeeze (crv.coefs(2,:,:)), 0.5, 2);
65 %! assert(ck, [0.25; 1; 2]);
66 %! ck = curvederiveval (crv.number-1, crv.order-1, crv.knots, squeeze (crv.coefs(3,:,:)), 0.5, 2);
67 %! assert(ck, [0.75; 1; -2]);