12 #include <unsupported/Eigen/Splines> 18 template class Spline<double, 2, Dynamic>;
19 template class Spline<double, 3, Dynamic>;
21 template class Spline<double, 2, 2>;
22 template class Spline<double, 2, 3>;
23 template class Spline<double, 2, 4>;
24 template class Spline<double, 2, 5>;
26 template class Spline<float, 2, Dynamic>;
27 template class Spline<float, 3, Dynamic>;
29 template class Spline<float, 3, 2>;
30 template class Spline<float, 3, 3>;
31 template class Spline<float, 3, 4>;
32 template class Spline<float, 3, 5>;
38 RowVectorXd knots(12);
53 ctrls << -0.370967741935484, 0.236842105263158,
54 -0.231401860693277, 0.442245185027632,
55 0.344361228532831, 0.773369994120753,
56 0.828990216203802, 0.106550882647595,
57 0.407270163678382, -1.043452922172848,
58 -0.488467813584053, -0.390098582530090,
59 -0.494657189446427, 0.054804824897884,
60 -0.370967741935484, 0.236842105263158;
61 ctrls.transposeInPlace();
63 return Spline<double, 2, Dynamic>(knots, ctrls);
69 RowVectorXd knots(11);
83 ctrls << 0.959743958516081, 0.340385726666133, 0.585267750979777,
84 0.223811939491137, 0.751267059305653, 0.255095115459269,
85 0.505957051665142, 0.699076722656686, 0.890903252535799,
86 0.959291425205444, 0.547215529963803, 0.138624442828679,
87 0.149294005559057, 0.257508254123736, 0.840717255983663,
88 0.254282178971531, 0.814284826068816, 0.243524968724989,
89 0.929263623187228, 0.349983765984809, 0.196595250431208,
90 0.251083857976031, 0.616044676146639, 0.473288848902729;
91 ctrls.transposeInPlace();
93 return Spline<double, 3, Dynamic>(knots, ctrls);
102 u << 0.351659507062997,
114 pts << 0.707620811535916, 0.510258911240815, 0.417485437023409,
115 0.603422256426978, 0.529498282727551, 0.270351549348981,
116 0.228364197569334, 0.423745615677815, 0.637687289287490,
117 0.275556796335168, 0.350856706427970, 0.684295784598905,
118 0.514519311047655, 0.525077224890754, 0.351628308305896,
119 0.724152914315666, 0.574461155457304, 0.469860285484058,
120 0.529365063753288, 0.613328702656816, 0.237837040141739,
121 0.522469395136878, 0.619099658652895, 0.237139665242069,
122 0.677357023849552, 0.480655768435853, 0.422227610314397,
123 0.247046593173758, 0.380604672404750, 0.670065791405019;
124 pts.transposeInPlace();
126 for (
int i=0; i<u.size(); ++i)
128 Vector3d pt = spline(u(i));
129 VERIFY( (pt - pts.col(i)).norm() < 1e-14 );
138 RowVectorXd u = spline.knots();
141 pts << 0.959743958516081, 0.340385726666133, 0.585267750979777,
142 0.959743958516081, 0.340385726666133, 0.585267750979777,
143 0.959743958516081, 0.340385726666133, 0.585267750979777,
144 0.430282980289940, 0.713074680056118, 0.720373307943349,
145 0.558074875553060, 0.681617921034459, 0.804417124839942,
146 0.407076008291750, 0.349707710518163, 0.617275937419545,
147 0.240037008286602, 0.738739390398014, 0.324554153129411,
148 0.302434111480572, 0.781162443963899, 0.240177089094644,
149 0.251083857976031, 0.616044676146639, 0.473288848902729,
150 0.251083857976031, 0.616044676146639, 0.473288848902729,
151 0.251083857976031, 0.616044676146639, 0.473288848902729;
152 pts.transposeInPlace();
154 for (
int i=0; i<u.size(); ++i)
156 Vector3d pt = spline(u(i));
157 VERIFY( (pt - pts.col(i)).norm() < 1e-14 );
180 pts << -0.370967741935484, 0.236842105263158,
181 -0.152576775123250, 0.448975001279334,
182 -0.133417538277668, 0.461615613865667,
183 -0.053199060826740, 0.507630360006299,
184 0.114249591147281, 0.570414135097409,
185 0.377810316891987, 0.560497102875315,
186 0.665052120135908, -0.157557441109611,
187 0.516006487053228, -0.559763292174825,
188 -0.379486035348887, -0.331959640488223,
189 -0.462034726249078, -0.039105670080824,
190 -0.378730600917982, 0.225127015099919,
191 -0.370967741935484, 0.236842105263158;
192 pts.transposeInPlace();
194 for (
int i=0; i<u.size(); ++i)
196 Vector2d pt = spline(u(i));
197 VERIFY( (pt - pts.col(i)).norm() < 1e-14 );
207 ControlPointVectorType points = ControlPointVectorType::Random(2,100);
209 KnotVectorType chord_lengths;
218 PointType pt = spline( chord_lengths(i) );
219 PointType ref = points.col(i);
220 VERIFY( (pt - ref).matrix().norm() < 1e-14 );
230 PointType pt = spline( chord_lengths(i) );
231 PointType ref = points.col(i);
232 VERIFY( (pt - ref).matrix().norm() < 1e-14 );
243 const unsigned int dimension = 2;
244 const unsigned int degree = 3;
246 ArrayXXd points = ArrayXXd::Random(dimension, numPoints);
248 KnotVectorType knots;
251 ArrayXXd derivatives = ArrayXXd::Random(dimension, numPoints);
252 VectorXd derivativeIndices(numPoints);
255 derivativeIndices(i) =
static_cast<double>(i);
258 points, derivatives, derivativeIndices, degree);
262 PointType point = spline(knots(i));
263 PointType referencePoint = points.col(i);
264 VERIFY_IS_APPROX(point, referencePoint);
265 PointType derivative = spline.derivatives(knots(i), 1).col(1);
266 PointType referenceDerivative = derivatives.col(i);
267 VERIFY_IS_APPROX(derivative, referenceDerivative);
273 for (
int i = 0; i < g_repeat; ++i)
void eval_spline3d_onbrks()
SplineTraits< Spline >::PointType PointType
The point type the spline is representing.
void eval_closed_spline2d()
void check_global_interpolation2d()
static SplineType InterpolateWithDerivatives(const PointArrayType &points, const PointArrayType &derivatives, const IndexArray &derivativeIndices, const unsigned int degree)
Fits an interpolating spline to the given data points and derivatives.
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
SplineTraits< Spline >::ControlPointVectorType ControlPointVectorType
The data type representing the spline's control points.
static SplineType Interpolate(const PointArrayType &pts, DenseIndex degree)
Fits an interpolating Spline to the given data points.
void ChordLengths(const PointArrayType &pts, KnotVectorType &chord_lengths)
Computes chord length parameters which are required for spline interpolation.
void check_global_interpolation_with_derivatives2d()
Spline< double, 3, Dynamic > spline3d()
SplineTraits< Spline >::KnotVectorType KnotVectorType
The data type used to store knot vectors.
Spline< double, 2, Dynamic > closed_spline2d()
Spline< double, 3 > Spline3d
3D double B-spline with dynamic degree.
Spline< double, 2 > Spline2d
2D double B-spline with dynamic degree.