1 function p = bspeval(d,c,k,u)
3 % BSPEVAL: Evaluate B-Spline at parametric points.
11 % d - Degree of the B-Spline.
12 % c - Control Points, matrix of size (dim,nc).
13 % k - Knot sequence, row vector of size nk.
14 % u - Parametric evaluation points, row vector of size nu.
18 % p - Evaluated points, matrix of size (dim,nu)
20 % Copyright (C) 2000 Mark Spink, 2007 Daniel Claxton, 2010 C. de Falco
22 % This program is free software: you can redistribute it and/or modify
23 % it under the terms of the GNU General Public License as published by
24 % the Free Software Foundation, either version 2 of the License, or
25 % (at your option) any later version.
27 % This program is distributed in the hope that it will be useful,
28 % but WITHOUT ANY WARRANTY; without even the implied warranty of
29 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 % GNU General Public License for more details.
32 % You should have received a copy of the GNU General Public License
33 % along with this program. If not, see <http://www.gnu.org/licenses/>.
37 % int bspeval(int d, double *c, int mc, int nc, double *k, int nk, double *u,int nu, double *p){
39 % int i, s, tmp1, row, col;
42 % // Construct the control points
43 % double **ctrl = vec2mat(c,mc,nc);
45 % // Contruct the evaluated points
46 p = zeros(mc,nu); % double **pnt = vec2mat(p,mc,nu);
48 % // space for the basis functions
49 %N = zeros(d+1,1); % double *N = (double*) mxMalloc((d+1)*sizeof(double));
51 % // for each parametric point i
52 %for col=1:nu % for (col = 0; col < nu; col++) {
53 % // find the span of u[col]
54 s = findspan(nc-1, d, u(:), k); % s = findspan(nc-1, d, u[col], k);
55 N = basisfun(s,u(:),d,k); % basisfun(s, u[col], d, k, N);
57 tmp1 = s - d + 1; % tmp1 = s - d;
58 %for row=1:mc % for (row = 0; row < mc; row++) {
59 p = zeros (mc, nu); % tmp2 = 0.0;
60 for i=0:d % for (i = 0; i <= d; i++)
61 p = p + repmat (N(:,i+1)', mc, 1).*c(:,tmp1+i); % tmp2 += N[i] * ctrl[tmp1+i][row];
63 %p(row,:) = tmp2; % pnt[col][row] = tmp2;