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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
2 % __NRB_CRV_BASISFUN_DER__: Undocumented internal function
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
3 %
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
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
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
7 % This software comes with ABSOLUTELY NO WARRANTY; see the file
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
8 % COPYING for details. This is free software, and you are welcome
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
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
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
11 n = size (nrb.coefs, 2) -1;
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
12 p = nrb.order -1;
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
13 u = points;
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
14 U = nrb.knots;
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
15 w = nrb.coefs(4,:);
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
16
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
17 spu = findspan (n, p, u, U);
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
18 nbfu = numbasisfun (spu, u, p, U);
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
19
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
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
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
23
11689
a5e636ebf237 Fixed bug for one single point. Compute function value and derivative with basisfunder
rafavzqz
parents: 6910
diff changeset
24
6910
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
25 [Dpc, Dpk] = bspderiv (p, w, U);
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
26 D = bspeval (p, w, U, u);
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
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
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
29
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
30 Bu1 = bsxfun (@(np, d) np/d , Nprime.', D);
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
31 Bu2 = bsxfun (@(n, dp) n*dp, N.', Dprime./D.^2);
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
32 Bu = w(nbfu+1) .* (Bu1 - Bu2).';
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
33
97806581afd6 New version compatible with Matlab
rafavzqz
parents:
diff changeset
34 end