]> Creatis software - CreaPhase.git/blob - octave_packages/nurbs-1.3.6/kntuniform.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nurbs-1.3.6 / kntuniform.m
1 % KNTUNIFORM: generate uniform open knot vectors in the reference domain.
2 %
3 %   [csi, zeta] = kntuniform (num, degree, regularity)
4 %
5 % INPUT:
6 %     
7 %     num:        number of breaks (in each direction)
8 %     degree:     polynomial degree (in each direction)
9 %     regularity: global regularity (in each direction)
10 %
11 % OUTPUT:
12 %
13 %     csi:  knots
14 %     zeta: breaks = knots without repetitions
15
16 % Copyright (C) 2009, 2010 Carlo de Falco
17 % Copyright (C) 2011 Rafael Vazquez
18 %
19 %    This program is free software: you can redistribute it and/or modify
20 %    it under the terms of the GNU General Public License as published by
21 %    the Free Software Foundation, either version 2 of the License, or
22 %    (at your option) any later version.
23
24 %    This program is distributed in the hope that it will be useful,
25 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
26 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27 %    GNU General Public License for more details.
28 %
29 %    You should have received a copy of the GNU General Public License
30 %    along with this program.  If not, see <http://www.gnu.org/licenses/>.
31
32 function [csi, zeta] = kntuniform (num, degree, regularity)
33   
34   if (numel(num)~=numel(degree) || numel(num)~=numel(regularity))
35     error('kntuniform: num, degree and regularity must have the same length')
36   else
37     for idim=1:numel(num)
38       zeta{idim} = linspace (0, 1, num(idim));
39       rep  = degree(idim) - regularity(idim);
40       if (rep > 0)
41         csi{idim}  = [zeros(1, degree(idim)+1-rep)...
42           reshape(repmat(zeta{idim}, rep, 1), 1, []) ones(1, degree(idim)+1-rep)];
43       else
44         error ('kntuniform: regularity requested is too high')
45       end
46     end
47     if (numel(num) == 1)
48       csi = csi{1};
49       zeta = zeta{1};
50     end
51   end
52 end