10 #ifndef EIGEN_SPLINE_FITTING_H 11 #define EIGEN_SPLINE_FITTING_H 15 #include "SplineFwd.h" 40 template <
typename KnotVectorType>
41 void KnotAveraging(
const KnotVectorType& parameters, DenseIndex degree, KnotVectorType& knots)
43 knots.resize(parameters.size()+degree+1);
45 for (DenseIndex j=1; j<parameters.size()-degree; ++j)
46 knots(j+degree) = parameters.segment(j,degree).mean();
48 knots.segment(0,degree+1) = KnotVectorType::Zero(degree+1);
49 knots.segment(knots.size()-degree-1,degree+1) = KnotVectorType::Ones(degree+1);
61 template <
typename Po
intArrayType,
typename KnotVectorType>
62 void ChordLengths(
const PointArrayType& pts, KnotVectorType& chord_lengths)
66 const DenseIndex n = pts.cols();
69 chord_lengths.resize(pts.cols());
71 chord_lengths.rightCols(n-1) = (pts.array().leftCols(n-1) - pts.array().rightCols(n-1)).matrix().colwise().norm();
74 std::partial_sum(chord_lengths.data(), chord_lengths.data()+n, chord_lengths.data());
77 chord_lengths /= chord_lengths(n-1);
78 chord_lengths(n-1) =
Scalar(1);
85 template <
typename SplineType>
88 typedef typename SplineType::KnotVectorType KnotVectorType;
98 template <
typename Po
intArrayType>
99 static SplineType
Interpolate(
const PointArrayType& pts, DenseIndex degree);
110 template <
typename Po
intArrayType>
111 static SplineType
Interpolate(
const PointArrayType& pts, DenseIndex degree,
const KnotVectorType& knot_parameters);
114 template <
typename SplineType>
115 template <
typename Po
intArrayType>
119 typedef typename SplineType::ControlPointVectorType ControlPointVectorType;
123 KnotVectorType knots;
126 DenseIndex n = pts.cols();
127 MatrixType A = MatrixType::Zero(n,n);
128 for (DenseIndex i=1; i<n-1; ++i)
130 const DenseIndex span = SplineType::Span(knot_parameters[i], degree, knots);
133 A.row(i).segment(span-degree, degree+1) = SplineType::BasisFunctions(knot_parameters[i], degree, knots);
141 ControlPointVectorType ctrls = qr.
solve(MatrixType(pts.transpose())).transpose();
143 return SplineType(knots, ctrls);
146 template <
typename SplineType>
147 template <
typename Po
intArrayType>
150 KnotVectorType chord_lengths;
156 #endif // EIGEN_SPLINE_FITTING_H
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
Spline fitting methods.
Definition: SplineFitting.h:86
void ChordLengths(const PointArrayType &pts, KnotVectorType &chord_lengths)
Computes chord length parameters which are required for spline interpolation.
Definition: SplineFitting.h:62
void KnotAveraging(const KnotVectorType ¶meters, DenseIndex degree, KnotVectorType &knots)
Computes knot averages.
Definition: SplineFitting.h:41
static SplineType Interpolate(const PointArrayType &pts, DenseIndex degree)
Fits an interpolating Spline to the given data points.
Definition: SplineFitting.h:148
const internal::solve_retval< HouseholderQR, Rhs > solve(const MatrixBase< Rhs > &b) const
This method finds a solution x to the equation Ax=b, where A is the matrix of which *this is the QR d...
Definition: HouseholderQR.h:122
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48