home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 5.ddi / SPLINES.DI$ / CSCVN.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  970 b   |  32 lines

  1. function cs = cscvn(points)
  2. % CSCVN    Generate an interpolating parametric cubic spline curve.
  3. %
  4. %        cs = cscvn(points)
  5. %
  6. % returns a parametric `natural' cubic spline which interpolates to the given 
  7. % points points(:,i)  at parameter values  t(i) , i=1,2,..., with  t(i)  chosen 
  8. % by Eugene Lee's centripetal scheme, i.e., as accumulated squareroot of 
  9. % chord-length.
  10.  
  11. % C. de Boor / latest change: Jan.28, 1990
  12. %              latest change: May 12, 1991 change from csapn to csape
  13. % Copyright (c) 1990-92 by Carl de Boor and The MathWorks, Inc.
  14.  
  15. [d,n] = size(points);
  16.  
  17. t=cumsum([0;((diff(points').^2)*ones(d,1)).^(1/4)])';
  18.  
  19. cs = csape(t,points(1,:),[2 2]);
  20.  
  21. if (d>1),
  22.    [breaks,coef,l,k] = ppbrk(cs);
  23.    coefs=zeros(d,l*k);
  24.    coefs(1,:)=coef(:)';
  25.    for dd=2:d
  26.       [breaks,coef] = ppbrk(csape(t,points(dd,:),[2 2]));
  27.       coefs(dd,:)=coef(:)';
  28.    end
  29.    temp = zeros(d*l,k); temp(:) = coefs;
  30.    cs = ppmak(breaks,temp,d);
  31. end
  32.