]> Creatis software - CreaPhase.git/blob - octave_packages/nurbs-1.3.6/numbasisfun.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nurbs-1.3.6 / numbasisfun.m
1 function B = numbasisfun (iv, uv, p, U)
2
3 % NUMBASISFUN:  List non-zero Basis functions for B-Spline in a given knot-span
4 %
5 % Calling Sequence:
6
7 %   N = numbasisfun(i,u,p,U)
8 %   
9 %    INPUT:
10 %   
11 %      i - knot span  ( from FindSpan() )
12 %      u - parametric point
13 %      p - spline degree
14 %      U - knot sequence
15 %   
16 %    OUTPUT:
17 %   
18 %      N - Basis functions (numel(u)x(p+1))
19 %   
20 %    Copyright (C) 2009 Carlo de Falco
21 %
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.
26
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.
31 %
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/>.
34
35 B = bsxfun (@(a, b) a+b,iv-p, (0:p).').';
36
37 end
38
39 %!test
40 %!  n = 3; 
41 %!  U = [0 0 0 1/2 1 1 1]; 
42 %!  p = 2; 
43 %!  u = linspace (0, 1, 10);  
44 %!  s = findspan (n, p, u, U); 
45 %!  Bref = [0   0   0   0   0   1   1   1   1   1; ...
46 %!          1   1   1   1   1   2   2   2   2   2; ...
47 %!          2   2   2   2   2   3   3   3   3   3].';
48 %!  B = numbasisfun (s, u, p, U);
49 %!  assert (B, Bref)