10 #ifndef EIGEN_SPLINE_H 11 #define EIGEN_SPLINE_H 34 template <
typename _Scalar,
int _Dim,
int _Degree>
80 template <
typename OtherVectorType,
typename OtherArrayType>
87 template <
int OtherDegree>
134 template <
int DerivativeOrder>
178 template <
int DerivativeOrder>
224 template <
typename DerivativeType>
233 template <
typename _Scalar,
int _Dim,
int _Degree>
241 const Scalar* pos = std::upper_bound(knots.data()+degree-1, knots.data()+knots.size()-degree-1, u);
242 return static_cast<DenseIndex>( std::distance(knots.data(), pos) - 1 );
245 template <
typename _Scalar,
int _Dim,
int _Degree>
259 BasisVectorType left(p+1); left(0) =
Scalar(0);
260 BasisVectorType right(p+1); right(0) =
Scalar(0);
265 BasisVectorType
N(1,p+1);
272 const Scalar tmp =
N(r)/(right(r+1)+left(j-r));
273 N[r] = saved + right(r+1)*tmp;
274 saved = left(j-r)*tmp;
281 template <
typename _Scalar,
int _Dim,
int _Degree>
290 template <
typename _Scalar,
int _Dim,
int _Degree>
296 template <
typename _Scalar,
int _Dim,
int _Degree>
307 return (ctrl_weights * ctrl_pts).rowwise().sum();
312 template <
typename SplineType,
typename DerivativeType>
317 enum { DerivativeOrder = DerivativeType::ColsAtCompileTime };
331 const BasisDerivativeType basis_func_ders = spline.template basisFunctionDerivatives<DerivativeOrder>(u, n+1);
334 for (
DenseIndex der_order=0; der_order<n+1; ++der_order)
338 der.col(der_order) = (ctrl_weights * ctrl_pts).rowwise().sum();
342 template <
typename _Scalar,
int _Dim,
int _Degree>
351 template <
typename _Scalar,
int _Dim,
int _Degree>
352 template <
int DerivativeOrder>
361 template <
typename _Scalar,
int _Dim,
int _Degree>
371 template <
typename _Scalar,
int _Dim,
int _Degree>
372 template <
typename DerivativeType>
392 BasisVectorType left = BasisVectorType::Zero(p+1);
393 BasisVectorType right = BasisVectorType::Zero(p+1);
404 left[j] = u-U[span+1-j];
405 right[j] = U[span+j]-u;
411 ndu(j,r) = right[r+1]+left[j-r];
412 temp = ndu(r,j-1)/ndu(j,r);
414 ndu(r,j) =
static_cast<Scalar
>(saved+right[r+1] * temp);
415 saved = left[j-r] * temp;
418 ndu(j,j) =
static_cast<Scalar
>(saved);
421 for (j = p; j>=0; --j)
425 DerivativeType a(n+1,p+1);
434 for (
DenseIndex k=1; k<=static_cast<DenseIndex>(n); ++k)
442 a(s2,0) = a(s1,0)/ndu(pk+1,rk);
443 d = a(s2,0)*ndu(rk,pk);
449 if (r-1 <= pk) j2 = k-1;
452 for (j=j1; j<=j2; ++j)
454 a(s2,j) = (a(s1,j)-a(s1,j-1))/ndu(pk+1,rk+j);
455 d += a(s2,j)*ndu(rk+j,pk);
460 a(s2,k) = -a(s1,k-1)/ndu(pk+1,r);
461 d += a(s2,k)*ndu(r,pk);
464 N_(k,r) =
static_cast<Scalar
>(d);
465 j = s1; s1 = s2; s2 = j;
472 for (
DenseIndex k=1; k<=static_cast<DenseIndex>(n); ++k)
474 for (j=p; j>=0; --j) N_(k,j) *= r;
479 template <
typename _Scalar,
int _Dim,
int _Degree>
488 template <
typename _Scalar,
int _Dim,
int _Degree>
489 template <
int DerivativeOrder>
498 template <
typename _Scalar,
int _Dim,
int _Degree>
512 #endif // EIGEN_SPLINE_H
A class representing multi-dimensional spline curves.
void derivativesImpl(const SplineType &spline, typename SplineType::Scalar u, DenseIndex order, DerivativeType &der)
static BasisVectorType BasisFunctions(Scalar u, DenseIndex degree, const KnotVectorType &knots)
Returns the spline's non-zero basis functions.
SplineTraits< Spline >::PointType PointType
The point type the spline is representing.
DenseIndex degree() const
Returns the spline degree.
SplineTraits< Spline >::BasisDerivativeType BasisDerivativeType
The data type used to store the values of the basis function derivatives.
SplineTraits< Spline >::BasisVectorType basisFunctions(Scalar u) const
Computes the non-zero basis functions at the given site.
DenseIndex span(Scalar u) const
Returns the span within the knot vector in which u is falling.
static BasisDerivativeType BasisFunctionDerivatives(const Scalar u, const DenseIndex order, const DenseIndex degree, const KnotVectorType &knots)
Computes the non-zero spline basis function derivatives up to given order.
Expression of a fixed-size or dynamic-size sub-vector.
const ControlPointVectorType & ctrls() const
Returns the ctrls of the underlying spline.
ControlPointVectorType m_ctrls
Spline()
Creates a (constant) zero spline. For Splines with dynamic degree, the resulting degree will be 0...
Expression of the multiple replication of a matrix or vector.
SplineTraits< Spline >::ParameterVectorType ParameterVectorType
The data type used to store parameter vectors.
PointType operator()(Scalar u) const
Returns the spline value at a given site .
const Block< const Derived, 1, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > ConstRowXpr
static DenseIndex Span(typename SplineTraits< Spline >::Scalar u, DenseIndex degree, const typename SplineTraits< Spline >::KnotVectorType &knots)
Computes the spang within the provided knot vector in which u is falling.
SplineTraits< Spline >::BasisDerivativeType basisFunctionDerivatives(Scalar u, DenseIndex order) const
Computes the non-zero spline basis function derivatives up to given order.
const KnotVectorType & knots() const
Returns the knots of the underlying spline.
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
SplineTraits< Spline >::ControlPointVectorType ControlPointVectorType
The data type representing the spline's control points.
SplineTraits< Spline >::DerivativeType derivatives(Scalar u, DenseIndex order) const
Evaluation of spline derivatives of up-to given order.
Spline(const Spline< Scalar, Dimension, OtherDegree > &spline)
Copy constructor for splines.
Expression of a fixed-size or dynamic-size block.
Spline(const OtherVectorType &knots, const OtherArrayType &ctrls)
Creates a spline from a knot vector and control points.
General-purpose arrays with easy API for coefficient-wise operations.
SplineTraits< Spline >::BasisVectorType BasisVectorType
The data type used to store non-zero basis functions.
SplineTraits< Spline >::KnotVectorType KnotVectorType
The data type used to store knot vectors.
The matrix class, also used for vectors and row-vectors.
static void BasisFunctionDerivativesImpl(const typename Spline< _Scalar, _Dim, _Degree >::Scalar u, const DenseIndex order, const DenseIndex p, const typename Spline< _Scalar, _Dim, _Degree >::KnotVectorType &U, DerivativeType &N_)