Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## octave-cvsupdate

 [Octave-cvsupdate] SF.net SVN: octave:[5726] trunk/octave-forge/main/general/inst/adresamp2.m From: - 2009-04-21 08:26:58 ```Revision: 5726 http://octave.svn.sourceforge.net/octave/?rev=5726&view=rev Author: highegg Date: 2009-04-21 08:26:50 +0000 (Tue, 21 Apr 2009) Log Message: ----------- fix adresamp2 due to gradient changes Modified Paths: -------------- trunk/octave-forge/main/general/inst/adresamp2.m Modified: trunk/octave-forge/main/general/inst/adresamp2.m =================================================================== --- trunk/octave-forge/main/general/inst/adresamp2.m 2009-04-20 15:06:27 UTC (rev 5725) +++ trunk/octave-forge/main/general/inst/adresamp2.m 2009-04-21 08:26:50 UTC (rev 5726) @@ -45,8 +45,8 @@ dx = dx ./ ds; dy = dy ./ ds; # second derivatives - d2x = gradient (dx, ds); - d2y = gradient (dy, ds); + d2x = deriv2 (dx, ds); + d2y = deriv2 (dy, ds); # curvature k = abs (d2x .* dy - d2y .* dx); # curvature cut-off @@ -66,6 +66,18 @@ ys = interp1 (t, y, i); endfunction +# calculates second derivatives from first (non-uniform intervals), using local +# quadratic approximations. +function d2x = deriv2 (dx, dt) + n = length (dt); + if (n >= 2) + d2x = diff (dx) ./ (dt(1:n-1) + dt(2:n)); + d2x = [2*d2x(1); d2x(1:n-2) + d2x(2:n-1); 2*d2x(n-1)]; + else + d2x = zeros (n, 1); + endif +endfunction + %!demo %! R = 2; r = 3; d = 1.5; %! th = linspace (0, 2*pi, 1000); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```