1 function [dc,dk] = bspderiv(d,c,k)
3 % BSPDERIV: B-Spline derivative.
7 % [dc,dk] = bspderiv(d,c,k)
11 % d - degree of the B-Spline
12 % c - control points double matrix(mc,nc)
13 % k - knot sequence double vector(nk)
17 % dc - control points of the derivative double matrix(mc,nc)
18 % dk - knot sequence of the derivative double vector(nk)
20 % Modified version of Algorithm A3.3 from 'The NURBS BOOK' pg98.
22 % Copyright (C) 2000 Mark Spink, 2007 Daniel Claxton
24 % This program is free software: you can redistribute it and/or modify
25 % it under the terms of the GNU General Public License as published by
26 % the Free Software Foundation, either version 2 of the License, or
27 % (at your option) any later version.
29 % This program is distributed in the hope that it will be useful,
30 % but WITHOUT ANY WARRANTY; without even the implied warranty of
31 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 % GNU General Public License for more details.
34 % You should have received a copy of the GNU General Public License
35 % along with this program. If not, see <http://www.gnu.org/licenses/>.
40 % int bspderiv(int d, double *c, int mc, int nc, double *k, int nk, double *dc,
47 % double **ctrl = vec2mat(c,mc,nc);
49 % // control points of the derivative
50 dc = zeros(mc,nc-1); % double **dctrl = vec2mat(dc,mc,nc-1);
52 for i=0:nc-2 % for (i = 0; i < nc-1; i++) {
53 tmp = d / (k(i+d+2) - k(i+2)); % tmp = d / (k[i+d+1] - k[i+1]);
54 for j=0:mc-1 % for (j = 0; j < mc; j++) {
55 dc(j+1,i+1) = tmp*(c(j+1,i+2) - c(j+1,i+1)); % dctrl[i][j] = tmp * (ctrl[i+1][j] - ctrl[i][j]);
59 dk = zeros(1,nk-2); % j = 0;
60 for i=1:nk-2 % for (i = 1; i < nk-1; i++)
61 dk(i) = k(i+1); % dk[j++] = k[i];