1 function skl = surfderiveval (n, p, U, m, q, V, P, u, v, d)
3 % SURFDERIVEVAL: Compute the derivatives of a B-spline surface
5 % usage: skl = surfderiveval (n, p, U, m, q, V, P, u, v, d)
9 % n+1, m+1 = number of control points
13 % u,v = evaluation points
14 % d = derivative order
18 % skl (k+1, l+1) = surface differentiated k
19 % times in the u direction and l
20 % times in the v direction
22 % Adaptation of algorithm A3.8 from the NURBS book, pg115
24 % Copyright (C) 2009 Carlo de Falco
26 % This program is free software: you can redistribute it and/or modify
27 % it under the terms of the GNU General Public License as published by
28 % the Free Software Foundation, either version 2 of the License, or
29 % (at your option) any later version.
31 % This program is distributed in the hope that it will be useful,
32 % but WITHOUT ANY WARRANTY; without even the implied warranty of
33 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 % GNU General Public License for more details.
36 % You should have received a copy of the GNU General Public License
37 % along with this program. If not, see <http://www.gnu.org/licenses/>.
39 skl = zeros (d+1, d+1);
43 uspan = findspan (n, p, u, U);
45 Nu(1:ip+1,ip+1) = basisfun (uspan, u, ip, U)';
48 vspan = findspan (m, q, v, V);
50 Nv(1:ip+1,ip+1) = basisfun (vspan, v, ip, V)';
53 pkl = surfderivcpts (n, p, U, m, q, V, P, d, uspan-p, uspan, ...
63 tmp = tmp + Nu(j+1,p-k+1) * pkl(k+1,l+1,j+1,i+1);
65 skl(k+1,l+1) = skl(k+1,l+1) + Nv(i+1,q-l+1)*tmp;
76 %! [coef(2,:,:), coef(1,:,:)] = meshgrid (c, c);
77 %! srf = nrbmak (coef, {k, k});
78 %! skl = surfderiveval (srf.number(1)-1, ...
79 %! srf.order(1)-1, ...
81 %! srf.number(2)-1, ...
82 %! srf.order(2)-1, ...
84 %! squeeze(srf.coefs(1,:,:)), .5, .5, 1) ;
85 %! assert (skl, [.5 0; 1 0])
87 %! srf = nrbkntins (srf, {[], rand(1,2)});
88 %! skl = surfderiveval (srf.number(1)-1,...
89 %! srf.order(1)-1, ...
91 %! srf.number(2)-1,...
92 %! srf.order(2)-1, ...
94 %! squeeze(srf.coefs(1,:,:)), .5, .5, 1) ;
95 %! assert (skl, [.5 0; 1 0], 100*eps)