annotate +parametrization/dataSpline.m @ 1093:fdff002ebb32 feature/dataspline

Remove some comments in dataSpline()
author Martin Almquist <malmquist@stanford.edu>
date Fri, 05 Apr 2019 13:15:45 -0700
parents 47a72344db71
children 36d092a00040
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1089
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
1 % Accepts data points (t_i, f_i) and returns a Curve object,
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
2 % using spline interpolation.
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
3 % The spline curve is parametrized with the arc length parametrization
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
4 % to facilitate better grids.
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
5 %
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
6 % t_data - vector
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
7 % f_data - vector
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
8 % C - curve object
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
9 function C = dataSpline(t_data, f_data)
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
10
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
11 assert(length(t_data)==length(f_data),'Vectors must be same length');
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
12 m_data = length(t_data);
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
13
1093
fdff002ebb32 Remove some comments in dataSpline()
Martin Almquist <malmquist@stanford.edu>
parents: 1092
diff changeset
14 pp_g = spapi(4, t_data, f_data);
1092
47a72344db71 Bugfix in dataSpline(), reparameterize with parameter from 0 to 1 before using Curve.
Martin Almquist <malmquist@stanford.edu>
parents: 1091
diff changeset
15 pp_gp = fnder(pp_g);
1089
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
16
1092
47a72344db71 Bugfix in dataSpline(), reparameterize with parameter from 0 to 1 before using Curve.
Martin Almquist <malmquist@stanford.edu>
parents: 1091
diff changeset
17 % Reparametrize with parameter s from 0 to 1 to use Curve class
47a72344db71 Bugfix in dataSpline(), reparameterize with parameter from 0 to 1 before using Curve.
Martin Almquist <malmquist@stanford.edu>
parents: 1091
diff changeset
18 tmin = min(t_data);
47a72344db71 Bugfix in dataSpline(), reparameterize with parameter from 0 to 1 before using Curve.
Martin Almquist <malmquist@stanford.edu>
parents: 1091
diff changeset
19 tmax = max(t_data);
47a72344db71 Bugfix in dataSpline(), reparameterize with parameter from 0 to 1 before using Curve.
Martin Almquist <malmquist@stanford.edu>
parents: 1091
diff changeset
20 t = @(s) tmin + s*(tmax-tmin);
47a72344db71 Bugfix in dataSpline(), reparameterize with parameter from 0 to 1 before using Curve.
Martin Almquist <malmquist@stanford.edu>
parents: 1091
diff changeset
21 dt_ds = @(s) 0*s + (tmax-tmin);
47a72344db71 Bugfix in dataSpline(), reparameterize with parameter from 0 to 1 before using Curve.
Martin Almquist <malmquist@stanford.edu>
parents: 1091
diff changeset
22 g = @(s) [t(s); fnval(pp_g, t(s))];
47a72344db71 Bugfix in dataSpline(), reparameterize with parameter from 0 to 1 before using Curve.
Martin Almquist <malmquist@stanford.edu>
parents: 1091
diff changeset
23 gp = @(s) [dt_ds(s); fnval(pp_gp, t(s)).*dt_ds(s)];
1089
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
24
1092
47a72344db71 Bugfix in dataSpline(), reparameterize with parameter from 0 to 1 before using Curve.
Martin Almquist <malmquist@stanford.edu>
parents: 1091
diff changeset
25 % Create Curve object and reparametrize with arclength parametrization
1089
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
26 C = parametrization.Curve(g, gp);
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
27 C = C.arcLengthParametrization(m_data);
d7f6c10eab13 Add function parametrization/dataSpline which accepts data points and returns a Curve object consisting of a spline interpolant with the arclength parametrization.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
28 end