diff options
author | Hauke Heibel <hauke.heibel@gmail.com> | 2012-04-13 12:50:05 +0200 |
---|---|---|
committer | Hauke Heibel <hauke.heibel@gmail.com> | 2012-04-13 12:50:05 +0200 |
commit | 84c93b048ecab7c22291503e68c47b6e3264fbb0 (patch) | |
tree | dc7cd508b4442aed6d45147b82e8f364bb8ed34a /unsupported/Eigen/src/Splines | |
parent | f6a55083922dce680f6f89a18e0cc35406201571 (diff) |
Added spline interpolation with pre-defined knot parameters.
Diffstat (limited to 'unsupported/Eigen/src/Splines')
-rw-r--r-- | unsupported/Eigen/src/Splines/SplineFitting.h | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/unsupported/Eigen/src/Splines/SplineFitting.h b/unsupported/Eigen/src/Splines/SplineFitting.h index 195f869b8..3e8abbbce 100644 --- a/unsupported/Eigen/src/Splines/SplineFitting.h +++ b/unsupported/Eigen/src/Splines/SplineFitting.h @@ -102,38 +102,53 @@ namespace Eigen template <typename SplineType> struct SplineFitting { + typedef typename SplineType::KnotVectorType KnotVectorType; + /** * \brief Fits an interpolating Spline to the given data points. + * + * \param pts The points for which an interpolating spline will be computed. + * \param degree The degree of the interpolating spline. + * + * \returns A spline interpolating the initially provided points. **/ template <typename PointArrayType> static SplineType Interpolate(const PointArrayType& pts, DenseIndex degree); + + /** + * \brief Fits an interpolating Spline to the given data points. + * + * \param pts The points for which an interpolating spline will be computed. + * \param degree The degree of the interpolating spline. + * \param knot_parameters The knot parameters for the interpolation. + * + * \returns A spline interpolating the initially provided points. + **/ + template <typename PointArrayType> + static SplineType Interpolate(const PointArrayType& pts, DenseIndex degree, const KnotVectorType& knot_parameters); }; template <typename SplineType> template <typename PointArrayType> - SplineType SplineFitting<SplineType>::Interpolate(const PointArrayType& pts, DenseIndex degree) + SplineType SplineFitting<SplineType>::Interpolate(const PointArrayType& pts, DenseIndex degree, const KnotVectorType& knot_parameters) { typedef typename SplineType::KnotVectorType::Scalar Scalar; - typedef typename SplineType::KnotVectorType KnotVectorType; typedef typename SplineType::BasisVectorType BasisVectorType; typedef typename SplineType::ControlPointVectorType ControlPointVectorType; typedef Matrix<Scalar,Dynamic,Dynamic> MatrixType; - KnotVectorType chord_lengths; // knot parameters - ChordLengths(pts, chord_lengths); - KnotVectorType knots; - KnotAveraging(chord_lengths, degree, knots); + KnotAveraging(knot_parameters, degree, knots); DenseIndex n = pts.cols(); MatrixType A = MatrixType::Zero(n,n); for (DenseIndex i=1; i<n-1; ++i) { - const DenseIndex span = SplineType::Span(chord_lengths[i], degree, knots); + const DenseIndex span = SplineType::Span(knot_parameters[i], degree, knots); // The segment call should somehow be told the spline order at compile time. - A.row(i).segment(span-degree, degree+1) = SplineType::BasisFunctions(chord_lengths[i], degree, knots); + A.row(i).segment(span-degree, degree+1) = SplineType::BasisFunctions(knot_parameters[i], degree, knots); } A(0,0) = 1.0; A(n-1,n-1) = 1.0; @@ -145,6 +160,15 @@ namespace Eigen return SplineType(knots, ctrls); } + + template <typename SplineType> + template <typename PointArrayType> + SplineType SplineFitting<SplineType>::Interpolate(const PointArrayType& pts, DenseIndex degree) + { + KnotVectorType chord_lengths; // knot parameters + ChordLengths(pts, chord_lengths); + return Interpolate(pts, degree, chord_lengths); + } } #endif // EIGEN_SPLINE_FITTING_H |