Mercurial > repos > public > sbplib
changeset 1088:acf19ecd1338 feature/dataspline
Turn the helper function spline into a static method in the Curve class.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Thu, 04 Apr 2019 17:55:57 -0700 |
parents | ae4b090b5299 |
children | d7f6c10eab13 |
files | +parametrization/Curve.m |
diffstat | 1 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/+parametrization/Curve.m Wed Feb 20 16:14:15 2019 -0800 +++ b/+parametrization/Curve.m Thu Apr 04 17:55:57 2019 -0700 @@ -103,7 +103,7 @@ % 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 + tFunc = parametrization.Curve.spline(arcVec,tvec); % t as a function of arcLength L = obj.arcLength(0,1); arcPar = @(s) tFunc(s*L); @@ -259,8 +259,8 @@ gVec = g(t)'; gpVec = (D1*gVec)'; - gp1_fun = spline(t,gpVec(1,:)); - gp2_fun = spline(t,gpVec(2,:)); + gp1_fun = parametrization.Curve.spline(t,gpVec(1,:)); + gp2_fun = parametrization.Curve.spline(t,gpVec(2,:)); gp_out = @(t) [gp1_fun(t);gp2_fun(t)]; end @@ -279,6 +279,16 @@ obj = parametrization.Curve(@g_fun, @g_fun_deriv); end + % Returns a function handle to the spline. + function f = spline(tval,fval,spline_order) + default_arg('spline_order',4); + [m,~] = size(tval); + assert(m==1,'Need row vectors.'); + + f_spline = spapi( optknt(tval,spline_order), tval, fval ); + f = @(t) fnval(f_spline,t); + end + function obj = circle(c,r,phi) default_arg('phi',[0; 2*pi]) default_arg('c',[0; 0]) @@ -385,12 +395,3 @@ end end -% Returns a function handle to the spline. -function f = spline(tval,fval,spline_order) - default_arg('spline_order',4); - [m,~] = size(tval); - assert(m==1,'Need row vectors.'); - - f_spline = spapi( optknt(tval,spline_order), tval, fval ); - f = @(t) fnval(f_spline,t); -end