Mercurial > repos > public > sbplib
comparison +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 |
comparison
equal
deleted
inserted
replaced
1097:eec03e78c6f2 | 1098:36d092a00040 |
---|---|
101 assert(~isempty(obj.gp),'Curve has no derivative!'); | 101 assert(~isempty(obj.gp),'Curve has no derivative!'); |
102 | 102 |
103 % Construct arcLength function using splines | 103 % Construct arcLength function using splines |
104 tvec = linspace(0,1,N); | 104 tvec = linspace(0,1,N); |
105 arcVec = obj.arcLength(0,tvec); | 105 arcVec = obj.arcLength(0,tvec); |
106 tFunc = spline(arcVec,tvec); % t as a function of arcLength | 106 |
107 % t as a function of arcLength. Use linear interpolation to preserve monotonicity. | |
108 tFunc = @(arcLen)interp1(arcVec,tvec,arcLen, 'linear', 'extrap'); | |
109 | |
107 L = obj.arcLength(0,1); | 110 L = obj.arcLength(0,1); |
108 arcPar = @(s) tFunc(s*L); | 111 arcPar = @(s) tFunc(s*L); |
109 | 112 |
110 % New function and derivative | 113 % New function and derivative |
111 g_new = @(t)obj.g(arcPar(t)); | 114 g_new = @(t)obj.g(arcPar(t)); |