5683
|
1 /* Copyright (C) 2009 Carlo de Falco |
6958
|
2 |
|
3 This program is free software: you can redistribute it and/or modify |
5683
|
4 it under the terms of the GNU General Public License as published by |
11634
|
5 the Free Software Foundation, either version 3 of the License, or |
5683
|
6 (at your option) any later version. |
6958
|
7 |
5683
|
8 This program is distributed in the hope that it will be useful, |
|
9 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 GNU General Public License for more details. |
|
12 |
|
13 You should have received a copy of the GNU General Public License |
6958
|
14 along with this program. If not, see <http://www.gnu.org/licenses/>. |
5683
|
15 */ |
|
16 |
|
17 #include <octave/oct.h> |
|
18 #include "low_level_functions.h" |
|
19 |
|
20 DEFUN_DLD(basisfunder, args, nargout,"\n\ |
|
21 BASISFUNDER: B-Spline Basis function derivatives\n\ |
|
22 \n\ |
|
23 Calling Sequence:\n\ |
|
24 \n\ |
6958
|
25 ders = basisfunder (ii, pl, uu, k, nd)\n\ |
5683
|
26 \n\ |
|
27 INPUT:\n\ |
|
28 \n\ |
6958
|
29 ii - knot span\n\ |
5683
|
30 pl - degree of curve\n\ |
6958
|
31 uu - parametric points\n\ |
5683
|
32 k - knot vector\n\ |
|
33 nd - number of derivatives to compute\n\ |
|
34 \n\ |
|
35 OUTPUT:\n\ |
|
36 \n\ |
|
37 ders - ders(n, i, :) (i-1)-th derivative at n-th point\n\ |
6958
|
38 \n\ |
|
39 Adapted from Algorithm A2.3 from 'The NURBS BOOK' pg72. \n\ |
|
40 \n\ |
5683
|
41 ") |
|
42 { |
|
43 octave_value_list retval; |
|
44 |
|
45 const NDArray i = args(0).array_value (); |
|
46 int pl = args(1).int_value (); |
|
47 const NDArray u = args(2).array_value (); |
|
48 const RowVector U = args(3).row_vector_value (); |
|
49 int nd = args(4).int_value (); |
|
50 |
|
51 if (!error_state) |
|
52 { |
12672
|
53 if (i.numel () != u.numel ()) |
5683
|
54 print_usage (); |
|
55 |
12672
|
56 NDArray dersv (dim_vector (i.numel (), nd+1, pl+1), 0.0); |
5683
|
57 NDArray ders(dim_vector(nd+1, pl+1), 0.0); |
12672
|
58 for ( octave_idx_type jj(0); jj < i.numel (); jj++) |
5683
|
59 { |
|
60 basisfunder (int (i(jj)), pl, u(jj), U, nd, ders); |
|
61 |
|
62 for (octave_idx_type kk(0); kk < nd+1; kk++) |
|
63 for (octave_idx_type ll(0); ll < pl+1; ll++) |
|
64 { |
|
65 dersv(jj, kk, ll) = ders(kk, ll); |
|
66 } |
|
67 } |
|
68 retval(0) = dersv; |
|
69 } |
|
70 return retval; |
|
71 } |