10 #ifndef EIGEN_SPLINE_FITTING_H 11 #define EIGEN_SPLINE_FITTING_H 40 template <
typename KnotVectorType>
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)
64 typedef typename KnotVectorType::Scalar Scalar;
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>
98 template <
typename Po
intArrayType>
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>
118 typedef typename SplineType::KnotVectorType::Scalar Scalar;
119 typedef typename SplineType::ControlPointVectorType ControlPointVectorType;
127 MatrixType
A = MatrixType::Zero(n,n);
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>
156 #endif // EIGEN_SPLINE_FITTING_H
iterative scaling algorithm to equilibrate rows and column norms in matrices
const internal::solve_retval< HouseholderQR, Rhs > solve(const MatrixBase< Rhs > &b) const
void KnotAveraging(const KnotVectorType ¶meters, DenseIndex degree, KnotVectorType &knots)
Computes knot averages.The knots are computed as where is the degree and the number knots of the d...
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
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.
SplineType::KnotVectorType KnotVectorType