diff +parametrization/Curve.m @ 1098:36d092a00040 feature/dataspline

Bugfix Curve.arcLengthParametrization() by using linear interpolation instead of higher-order spline for parameter as a funciton of arclength. Generalize dataSpline() to curves in higher dimensions.
author Martin Almquist <malmquist@stanford.edu>
date Tue, 09 Apr 2019 09:50:44 -0700
parents ad3089f04e0b
children 7f4aae76e06a
line wrap: on
line diff
--- a/+parametrization/Curve.m	Mon Apr 08 22:30:47 2019 +0200
+++ b/+parametrization/Curve.m	Tue Apr 09 09:50:44 2019 -0700
@@ -103,7 +103,10 @@
             % Construct arcLength function using splines
             tvec = linspace(0,1,N);
             arcVec = obj.arcLength(0,tvec);
-            tFunc = spline(arcVec,tvec); % t as a function of arcLength
+
+            % t as a function of arcLength. Use linear interpolation to preserve monotonicity.
+            tFunc = @(arcLen)interp1(arcVec,tvec,arcLen, 'linear', 'extrap');
+
             L = obj.arcLength(0,1);
             arcPar = @(s) tFunc(s*L);