Mercurial > forge
annotate extra/nurbs/inst/private/nrb_crv_basisfun_der__.m @ 11689:a5e636ebf237 octave-forge
Fixed bug for one single point. Compute function value and derivative with basisfunder
author | rafavzqz |
---|---|
date | Wed, 08 May 2013 12:49:14 +0000 |
parents | 97806581afd6 |
children |
rev | line source |
---|---|
11689
a5e636ebf237
Fixed bug for one single point. Compute function value and derivative with basisfunder
rafavzqz
parents:
6910
diff
changeset
|
1 function [Bu, nbfu] = nrb_crv_basisfun_der__ (points, nrb) |
6910 | 2 % __NRB_CRV_BASISFUN_DER__: Undocumented internal function |
3 % | |
4 % Copyright (C) 2009 Carlo de Falco | |
11689
a5e636ebf237
Fixed bug for one single point. Compute function value and derivative with basisfunder
rafavzqz
parents:
6910
diff
changeset
|
5 % Copyright (C) 2013 Rafael Vazquez |
a5e636ebf237
Fixed bug for one single point. Compute function value and derivative with basisfunder
rafavzqz
parents:
6910
diff
changeset
|
6 % |
6910 | 7 % This software comes with ABSOLUTELY NO WARRANTY; see the file |
8 % COPYING for details. This is free software, and you are welcome | |
9 % to distribute it under the conditions laid out in COPYING. | |
11689
a5e636ebf237
Fixed bug for one single point. Compute function value and derivative with basisfunder
rafavzqz
parents:
6910
diff
changeset
|
10 |
6910 | 11 n = size (nrb.coefs, 2) -1; |
12 p = nrb.order -1; | |
13 u = points; | |
14 U = nrb.knots; | |
15 w = nrb.coefs(4,:); | |
16 | |
17 spu = findspan (n, p, u, U); | |
18 nbfu = numbasisfun (spu, u, p, U); | |
19 | |
20 Nprime = basisfunder (spu, p, u, U, 1); | |
11689
a5e636ebf237
Fixed bug for one single point. Compute function value and derivative with basisfunder
rafavzqz
parents:
6910
diff
changeset
|
21 N = reshape (Nprime(:,1,:), numel(u), p+1); |
a5e636ebf237
Fixed bug for one single point. Compute function value and derivative with basisfunder
rafavzqz
parents:
6910
diff
changeset
|
22 Nprime = reshape (Nprime(:,2,:), numel(u), p+1); |
6910 | 23 |
11689
a5e636ebf237
Fixed bug for one single point. Compute function value and derivative with basisfunder
rafavzqz
parents:
6910
diff
changeset
|
24 |
6910 | 25 [Dpc, Dpk] = bspderiv (p, w, U); |
26 D = bspeval (p, w, U, u); | |
27 Dprime = bspeval (p-1, Dpc, Dpk, u); | |
11689
a5e636ebf237
Fixed bug for one single point. Compute function value and derivative with basisfunder
rafavzqz
parents:
6910
diff
changeset
|
28 |
6910 | 29 |
30 Bu1 = bsxfun (@(np, d) np/d , Nprime.', D); | |
31 Bu2 = bsxfun (@(n, dp) n*dp, N.', Dprime./D.^2); | |
32 Bu = w(nbfu+1) .* (Bu1 - Bu2).'; | |
33 | |
34 end |