Mercurial > repos > public > sbplib
comparison +parametrization/dataSpline.m @ 1092:47a72344db71 feature/dataspline
Bugfix in dataSpline(), reparameterize with parameter from 0 to 1 before using Curve.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Fri, 05 Apr 2019 13:14:29 -0700 |
parents | b4054942e277 |
children | fdff002ebb32 |
comparison
equal
deleted
inserted
replaced
1091:b4054942e277 | 1092:47a72344db71 |
---|---|
11 assert(length(t_data)==length(f_data),'Vectors must be same length'); | 11 assert(length(t_data)==length(f_data),'Vectors must be same length'); |
12 m_data = length(t_data); | 12 m_data = length(t_data); |
13 | 13 |
14 pp_g = spapi(4, t_data, f_data); % equivalent to g = spapi(aptknt(t_data, 4), t_data, f_data) | 14 pp_g = spapi(4, t_data, f_data); % equivalent to g = spapi(aptknt(t_data, 4), t_data, f_data) |
15 % or (not sure what the difference is?!) | 15 % or (not sure what the difference is?!) |
16 % g = spapi(optknt(t_data, 4), t_data, f_data) | 16 % pp_g = spapi(optknt(t_data, 4), t_data, f_data) |
17 pp_gp = fnder(g); | 17 pp_gp = fnder(pp_g); |
18 | 18 |
19 g = @(t)fnval(pp_g, t); | 19 % Reparametrize with parameter s from 0 to 1 to use Curve class |
20 pp_gp = @(t)fnval(pp_gp, t); | 20 tmin = min(t_data); |
21 tmax = max(t_data); | |
22 t = @(s) tmin + s*(tmax-tmin); | |
23 dt_ds = @(s) 0*s + (tmax-tmin); | |
24 g = @(s) [t(s); fnval(pp_g, t(s))]; | |
25 gp = @(s) [dt_ds(s); fnval(pp_gp, t(s)).*dt_ds(s)]; | |
21 | 26 |
27 % Create Curve object and reparametrize with arclength parametrization | |
22 C = parametrization.Curve(g, gp); | 28 C = parametrization.Curve(g, gp); |
23 | |
24 % Reparametrize with arclength parametrization | |
25 C = C.arcLengthParametrization(m_data); | 29 C = C.arcLengthParametrization(m_data); |
26 end | 30 end |