changeset 5617:89f4acabdc91 octave-forge

removed incompatibilities
author cdf
date Mon, 11 May 2009 12:45:32 +0000
parents b55d1f1c2e2b
children 9a609f4636fe
files extra/nurbs/inst/__nrb_srf_basisfun__.m extra/nurbs/inst/__nrb_srf_basisfun_der__.m extra/nurbs/inst/nrb_srf_basisfun__.m extra/nurbs/inst/nrb_srf_basisfun_der__.m extra/nurbs/inst/nrbbasisfun.m extra/nurbs/inst/nrbbasisfunder.m extra/nurbs/inst/nrbbasisfungradient.m extra/nurbs/inst/nrbnumbasisfun.m
diffstat 8 files changed, 156 insertions(+), 149 deletions(-) [+]
line wrap: on
line diff
--- a/extra/nurbs/inst/__nrb_srf_basisfun__.m	Mon May 11 12:11:16 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-%% Copyright (C) 2009 Carlo de Falco
-%% 
-%% This program is free software; you can redistribute it and/or modify
-%% it under the terms of the GNU General Public License as published by
-%% the Free Software Foundation; either version 2 of the License, or
-%% (at your option) any later version.
-%% 
-%% This program is distributed in the hope that it will be useful,
-%% but WITHOUT ANY WARRANTY; without even the implied warranty of
-%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%% GNU General Public License for more details.
-%% 
-%% You should have received a copy of the GNU General Public License
-%% along with this program; if not, see <http://www.gnu.org/licenses/>.
-
-function [B, N] = __nrb_srf_basisfun__ (points, nrb);
-
-  %%  __NRB_SRF_BASISFUN__: Undocumented internal function
-
-    m    = size (nrb.coefs, 2) -1;
-    n    = size (nrb.coefs, 3) -1;
-    
-    p    = nrb.order(1) -1;
-    q    = nrb.order(2) -1;
-
-    u = points(1,:);
-    v = points(2,:);
-    npt = length(u);
-
-    U    = nrb.knots{1};
-    V    = nrb.knots{2};
-    
-    w    = squeeze(nrb.coefs(4,:,:));
-
-    spu    = findspan (m, p, u, U); 
-    spv    = findspan (n, q, v, V);
-    NuIkuk = basisfun (spu, u, p, U);
-    NvJkvk = basisfun (spv, v, q, V);
-
-    indIkJk = nrbnumbasisfun (points, nrb);
-
-    for k=1:npt
-      wIkaJkb(1:p+1, 1:q+1) = reshape (w(indIkJk(k, :)), p+1, q+1); 
-      NuIkukaNvJkvk(1:p+1, 1:q+1) = (NuIkuk(k, :).' * NvJkvk(k, :));
-      RIkJk(k, :) = (NuIkukaNvJkvk .* wIkaJkb ./ sum(sum(NuIkukaNvJkvk .* wIkaJkb)))(:).';
-    end
-    
-    B = RIkJk;
-    N = indIkJk;
-    
-  end
\ No newline at end of file
--- a/extra/nurbs/inst/__nrb_srf_basisfun_der__.m	Mon May 11 12:11:16 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-%% Copyright (C) 2009 Carlo de Falco
-%% 
-%% This program is free software; you can redistribute it and/or modify
-%% it under the terms of the GNU General Public License as published by
-%% the Free Software Foundation; either version 2 of the License, or
-%% (at your option) any later version.
-%% 
-%% This program is distributed in the hope that it will be useful,
-%% but WITHOUT ANY WARRANTY; without even the implied warranty of
-%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%% GNU General Public License for more details.
-%% 
-%% You should have received a copy of the GNU General Public License
-%% along with this program; if not, see <http://www.gnu.org/licenses/>.
-
-function [Bu, Bv, N] = __nrb_srf_basisfun_der__ (points, nrb);
-
-  %%  __NRB_SRF_BASISFUN_DER__: Undocumented internal function
-
-  m    = size (nrb.coefs, 2) -1;
-  n    = size (nrb.coefs, 3) -1;
-  
-  p    = nrb.order(1) -1;
-  q    = nrb.order(2) -1;
-  
-  u = points(1,:);
-  v = points(2,:);
-  npt = length(u);
-  
-  U    = nrb.knots{1};
-  V    = nrb.knots{2};
-  
-  w    = squeeze(nrb.coefs(4,:,:));
-  
-  spu  =  findspan (m, p, u, U); 
-  Ik   =  numbasisfun (spu, u, p, U);
-  
-  spv  =  findspan (n, q, v, V);
-  Jk   =  numbasisfun (spv, v, q, V);
-  
-  NuIkuk = basisfun (spu, u, p, U);
-  NvJkvk = basisfun (spv, v, q, V);
-  
-  NuIkukprime = basisfunder (spu, p, u, U, 1);
-  NuIkukprime = squeeze(NuIkukprime(:,2,:));
-  
-  NvJkvkprime = basisfunder (spv, q, v, V, 1);
-  NvJkvkprime = squeeze(NvJkvkprime(:,2,:));
-  
-  
-  for k=1:npt
-    [Ika, Jkb] = meshgrid(Ik(k, :), Jk(k, :)); 
-    
-    N(k, :)    = sub2ind([m+1, n+1], Ika(:)+1, Jkb(:)+1);
-    wIkaJkb(1:p+1, 1:q+1) = reshape (w(N(k, :)), p+1, q+1); 
-    
-    Num    = (NuIkuk(k, :).' * NvJkvk(k, :)) .* wIkaJkb;
-    Num_du = (NuIkukprime(k, :).' * NvJkvk(k, :)) .* wIkaJkb;
-    Num_dv = (NuIkuk(k, :).' * NvJkvkprime(k, :)) .* wIkaJkb;
-    Denom  = sum(sum(Num));
-    Denom_du = sum(sum(Num_du));
-    Denom_dv = sum(sum(Num_dv));
-    
-    Bu(k, :) = (Num_du/Denom - Denom_du.*Num/Denom.^2)(:).';
-    Bv(k, :) = (Num_dv/Denom - Denom_dv.*Num/Denom.^2)(:).';
-  end
-  
-end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/nurbs/inst/nrb_srf_basisfun__.m	Mon May 11 12:45:32 2009 +0000
@@ -0,0 +1,51 @@
+%% Copyright (C) 2009 Carlo de Falco
+%% 
+%% This program is free software; you can redistribute it and/or modify
+%% it under the terms of the GNU General Public License as published by
+%% the Free Software Foundation; either version 2 of the License, or
+%% (at your option) any later version.
+%% 
+%% This program is distributed in the hope that it will be useful,
+%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%% GNU General Public License for more details.
+%% 
+%% You should have received a copy of the GNU General Public License
+%% along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+function [B, N] = nrb_srf_basisfun__ (points, nrb);
+
+  %%  __NRB_SRF_BASISFUN__: Undocumented internal function
+
+    m    = size (nrb.coefs, 2) -1;
+    n    = size (nrb.coefs, 3) -1;
+    
+    p    = nrb.order(1) -1;
+    q    = nrb.order(2) -1;
+
+    u = points(1,:);
+    v = points(2,:);
+    npt = length(u);
+
+    U    = nrb.knots{1};
+    V    = nrb.knots{2};
+    
+    w    = squeeze(nrb.coefs(4,:,:));
+
+    spu    = findspan (m, p, u, U); 
+    spv    = findspan (n, q, v, V);
+    NuIkuk = basisfun (spu, u, p, U);
+    NvJkvk = basisfun (spv, v, q, V);
+
+    indIkJk = nrbnumbasisfun (points, nrb);
+
+    for k=1:npt
+      wIkaJkb(1:p+1, 1:q+1) = reshape (w(indIkJk(k, :)), p+1, q+1); 
+      NuIkukaNvJkvk(1:p+1, 1:q+1) = (NuIkuk(k, :).' * NvJkvk(k, :));
+      RIkJk(k, :) = reshape((NuIkukaNvJkvk .* wIkaJkb ./ sum(sum(NuIkukaNvJkvk .* wIkaJkb))),1,[]);
+    end
+    
+    B = RIkJk;
+    N = indIkJk;
+    
+  end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/nurbs/inst/nrb_srf_basisfun_der__.m	Mon May 11 12:45:32 2009 +0000
@@ -0,0 +1,68 @@
+%% Copyright (C) 2009 Carlo de Falco
+%% 
+%% This program is free software; you can redistribute it and/or modify
+%% it under the terms of the GNU General Public License as published by
+%% the Free Software Foundation; either version 2 of the License, or
+%% (at your option) any later version.
+%% 
+%% This program is distributed in the hope that it will be useful,
+%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%% GNU General Public License for more details.
+%% 
+%% You should have received a copy of the GNU General Public License
+%% along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+function [Bu, Bv, N] = nrb_srf_basisfun_der__ (points, nrb);
+
+  %%  __NRB_SRF_BASISFUN_DER__: Undocumented internal function
+
+  m    = size (nrb.coefs, 2) -1;
+  n    = size (nrb.coefs, 3) -1;
+  
+  p    = nrb.order(1) -1;
+  q    = nrb.order(2) -1;
+  
+  u = points(1,:);
+  v = points(2,:);
+  npt = length(u);
+  
+  U    = nrb.knots{1};
+  V    = nrb.knots{2};
+  
+  w    = squeeze(nrb.coefs(4,:,:));
+  
+  spu  =  findspan (m, p, u, U); 
+  Ik   =  numbasisfun (spu, u, p, U);
+  
+  spv  =  findspan (n, q, v, V);
+  Jk   =  numbasisfun (spv, v, q, V);
+  
+  NuIkuk = basisfun (spu, u, p, U);
+  NvJkvk = basisfun (spv, v, q, V);
+  
+  NuIkukprime = basisfunder (spu, p, u, U, 1);
+  NuIkukprime = squeeze(NuIkukprime(:,2,:));
+  
+  NvJkvkprime = basisfunder (spv, q, v, V, 1);
+  NvJkvkprime = squeeze(NvJkvkprime(:,2,:));
+  
+  
+  for k=1:npt
+    [Ika, Jkb] = meshgrid(Ik(k, :), Jk(k, :)); 
+    
+    N(k, :)    = sub2ind([m+1, n+1], Ika(:)+1, Jkb(:)+1);
+    wIkaJkb(1:p+1, 1:q+1) = reshape (w(N(k, :)), p+1, q+1); 
+    
+    Num    = (NuIkuk(k, :).' * NvJkvk(k, :)) .* wIkaJkb;
+    Num_du = (NuIkukprime(k, :).' * NvJkvk(k, :)) .* wIkaJkb;
+    Num_dv = (NuIkuk(k, :).' * NvJkvkprime(k, :)) .* wIkaJkb;
+    Denom  = sum(sum(Num));
+    Denom_du = sum(sum(Num_du));
+    Denom_dv = sum(sum(Num_dv));
+    
+    Bu(k, :) = reshape((Num_du/Denom - Denom_du.*Num/Denom.^2),1,[]);
+    Bv(k, :) = reshape((Num_dv/Denom - Denom_dv.*Num/Denom.^2),1,[]);
+  end
+  
+end
\ No newline at end of file
--- a/extra/nurbs/inst/nrbbasisfun.m	Mon May 11 12:11:16 2009 +0000
+++ b/extra/nurbs/inst/nrbbasisfun.m	Mon May 11 12:45:32 2009 +0000
@@ -41,19 +41,19 @@
 %          point. size(N) == size(B)
 %   
 
-  if (   (nargin<2) 
-      || (nargout>2)
-      || (~isstruct(nrb))
-      || (iscell(points) && ~iscell(nrb.knots))
-      || (~iscell(points) && iscell(nrb.knots) && (size(points,1)~=2))
-      || (~iscell(nrb.knots) && (nargout>1))
+  if (   (nargin<2) ...
+      || (nargout>2) ...
+      || (~isstruct(nrb)) ...
+      || (iscell(points) && ~iscell(nrb.knots)) ...
+      || (~iscell(points) && iscell(nrb.knots) && (size(points,1)~=2)) ...
+      || (~iscell(nrb.knots) && (nargout>1)) ...
       )
     print_usage();
   end
                             
   if (~iscell(nrb.knots))    %% NURBS curve
     
-    [B, id] = __nrb_crv_basisfun__ (points, nrb);
+    [B, id] = nrb_crv_basisfun__ (points, nrb);
     
   else                       %% NURBS surface
 
@@ -66,11 +66,12 @@
       p = points;
     end
     
-    [B, id] = __nrb_srf_basisfun__ (p, nrb); 
+    [B, id] = nrb_srf_basisfun__ (p, nrb); 
 
   end
+end
 
-  function [B, nbfu] = __nrb_crv_basisfun__ (points, nrb);
+  function [B, nbfu] = nrb_crv_basisfun__ (points, nrb);
     n    = size (nrb.coefs, 2) -1;
     p    = nrb.order -1;
     u    = points;
--- a/extra/nurbs/inst/nrbbasisfunder.m	Mon May 11 12:11:16 2009 +0000
+++ b/extra/nurbs/inst/nrbbasisfunder.m	Mon May 11 12:45:32 2009 +0000
@@ -47,19 +47,19 @@
 %   
 
   
-  if (   (nargin<2) 
-      || (nargout>3)
-      || (~isstruct(nrb))
-      || (iscell(points) && ~iscell(nrb.knots))
-      || (~iscell(points) && iscell(nrb.knots) && (size(points,1)~=2))
-      || (~iscell(nrb.knots) && (nargout>2))
+  if (   (nargin<2) ...
+      || (nargout>3) ...
+      || (~isstruct(nrb)) ...
+      || (iscell(points) && ~iscell(nrb.knots)) ...
+      || (~iscell(points) && iscell(nrb.knots) && (size(points,1)~=2)) ...
+      || (~iscell(nrb.knots) && (nargout>2)) ...
       )
     print_usage();
   end
                             
   if (~iscell(nrb.knots))    %% NURBS curve
     
-    [varargout{1}, varargout{2}] = __nrb_crv_basisfun_der__ (points, nrb);
+    [varargout{1}, varargout{2}] = nrb_crv_basisfun_der__ (points, nrb);
 
   else                       %% NURBS surface
 
@@ -72,11 +72,12 @@
       p = points;
     end
     
-    [varargout{1}, varargout{2}, varargout{3}] = __nrb_srf_basisfun_der__ (p, nrb);
+    [varargout{1}, varargout{2}, varargout{3}] = nrb_srf_basisfun_der__ (p, nrb);
 
   end
+end
 
-  function [Bu, nbfu] = __nrb_crv_basisfun_der__ (points, nrb);
+  function [Bu, nbfu] = nrb_crv_basisfun_der__ (points, nrb);
     n    = size (nrb.coefs, 2) -1;
     p    = nrb.order -1;
     u    = points;
--- a/extra/nurbs/inst/nrbbasisfungradient.m	Mon May 11 12:11:16 2009 +0000
+++ b/extra/nurbs/inst/nrbbasisfungradient.m	Mon May 11 12:45:32 2009 +0000
@@ -52,10 +52,15 @@
     X = squeeze(nrb.coefs(1,:,:)./nrb.coefs(4,:,:));
     Y = squeeze(nrb.coefs(2,:,:)./nrb.coefs(4,:,:));
 
-    dxdu=sum(X(N).*dzdu, 2)(:, ones(columns(N),1)); 
-    dydu=sum(Y(N).*dzdu, 2)(:, ones(columns(N),1));
-    dxdv=sum(X(N).*dzdv, 2)(:, ones(columns(N),1));
-    dydv=sum(Y(N).*dzdv, 2)(:, ones(columns(N),1));
+    nfun = size(N,2);
+    tmp = sum(X(N).*dzdu, 2);
+    dxdu= tmp(:, ones(nfun,1)); 
+    tmp = sum(Y(N).*dzdu, 2);
+    dydu= tmp(:, ones(nfun,1));
+    tmp = sum(X(N).*dzdv, 2);
+    dxdv= tmp(:, ones(nfun,1));
+    tmp = sum(Y(N).*dzdv, 2);
+    dydv= tmp(:, ones(nfun,1));
     
     detjac = dxdu.*dydv - dydu.*dxdv;
     
--- a/extra/nurbs/inst/nrbnumbasisfun.m	Mon May 11 12:11:16 2009 +0000
+++ b/extra/nurbs/inst/nrbnumbasisfun.m	Mon May 11 12:45:32 2009 +0000
@@ -36,11 +36,11 @@
 %          point. size(N) == size(B)
 %   
 
-  if (   (nargin<2) 
-      || (nargout>1)
-      || (~isstruct(nrb))
-      || (iscell(points) && ~iscell(nrb.knots))
-      || (~iscell(points) && iscell(nrb.knots) && (size(points,1)~=2))
+  if (   (nargin<2) ...
+      || (nargout>1) ...
+      || (~isstruct(nrb)) ...
+      || (iscell(points) && ~iscell(nrb.knots)) ...
+      || (~iscell(points) && iscell(nrb.knots) && (size(points,1)~=2)) ...
       )
     print_usage();
   end
@@ -62,18 +62,18 @@
       p = points;
     end
     
-    idx = __nrb_srf_numbasisfun__ (p, nrb); 
+    idx = nrb_srf_numbasisfun__ (p, nrb); 
 
   end
   
 end
 
-function idx = __nrb_srf_numbasisfun__ (points, nrb)
+function idx = nrb_srf_numbasisfun__ (points, nrb)
   
   m   = nrb.number(1)-1;
   n   = nrb.number(2)-1;
   
-  npt = columns(points);
+  npt = size(points,2);
   u   = points(1,:);
   v   = points(2,:);