annotate +parametrization/dataSpline.m @ 1091:b4054942e277 feature/dataspline

Rewrite dataSpline() avoiding the spline function in Curve and using fnder for the differentiation
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 05 Apr 2019 10:17:04 +0200
parents d7f6c10eab13
children 47a72344db71
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
1091
b4054942e277 Rewrite dataSpline() avoiding the spline function in Curve and using fnder for the differentiation
Jonatan Werpers <jonatan@werpers.com>
parents: 1089
diff changeset
14 pp_g = spapi(4, t_data, f_data); % equivalent to g = spapi(aptknt(t_data, 4), t_data, f_data)
b4054942e277 Rewrite dataSpline() avoiding the spline function in Curve and using fnder for the differentiation
Jonatan Werpers <jonatan@werpers.com>
parents: 1089
diff changeset
15 % or (not sure what the difference is?!)
b4054942e277 Rewrite dataSpline() avoiding the spline function in Curve and using fnder for the differentiation
Jonatan Werpers <jonatan@werpers.com>
parents: 1089
diff changeset
16 % g = spapi(optknt(t_data, 4), t_data, f_data)
b4054942e277 Rewrite dataSpline() avoiding the spline function in Curve and using fnder for the differentiation
Jonatan Werpers <jonatan@werpers.com>
parents: 1089
diff changeset
17 pp_gp = fnder(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
18
1091
b4054942e277 Rewrite dataSpline() avoiding the spline function in Curve and using fnder for the differentiation
Jonatan Werpers <jonatan@werpers.com>
parents: 1089
diff changeset
19 g = @(t)fnval(pp_g, t);
b4054942e277 Rewrite dataSpline() avoiding the spline function in Curve and using fnder for the differentiation
Jonatan Werpers <jonatan@werpers.com>
parents: 1089
diff changeset
20 pp_gp = @(t)fnval(pp_gp, t);
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
21
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
22 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
23
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 % Reparametrize with arclength 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
25 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
26 end