Aikido
aikido::common::BSpline< _Scalar, _Dim, _Degree > Class Template Reference

#include <aikido/common/BSpline.hpp>

Public Types

enum  { Dimension = _Dim }
 
enum  { Degree = _Degree }
 
typedef _Scalar Scalar
 
typedef SplineTraits< BSpline >::PointType PointType
 The point type the spline is representing. More...
 
typedef SplineTraits< BSpline >::KnotVectorType KnotVectorType
 The data type used to store knot vectors. More...
 
typedef SplineTraits< BSpline >::ParameterVectorType ParameterVectorType
 The data type used to store parameter vectors. More...
 
typedef SplineTraits< BSpline >::BasisVectorType BasisVectorType
 The data type used to store non-zero basis functions. More...
 
typedef SplineTraits< BSpline >::BasisDerivativeType BasisDerivativeType
 The data type used to store the values of the basis function derivatives. More...
 
typedef SplineTraits< BSpline >::ControlPointVectorType ControlPointVectorType
 The data type representing the spline's control points. More...
 

Public Member Functions

 BSpline ()
 Creates a (constant) zero spline. More...
 
template<typename OtherVectorType , typename OtherArrayType >
 BSpline (const OtherVectorType &knots, const OtherArrayType &ctrls)
 Creates a spline from a knot vector and control points. More...
 
template<int OtherDegree>
 BSpline (const BSpline< Scalar, Dimension, OtherDegree > &spline)
 Copy constructor for splines. More...
 
const KnotVectorType & knots () const
 Returns the knots of the underlying spline. More...
 
ControlPointVectorType & ctrls ()
 Returns the ctrls of the underlying spline. More...
 
const ControlPointVectorType & ctrls () const
 Returns the ctrls of the underlying spline. More...
 
PointType operator() (Scalar u) const
 Returns the spline value at a given site $u$. More...
 
SplineTraits< BSpline >::DerivativeType derivatives (Scalar u, Eigen::DenseIndex order) const
 Evaluation of spline derivatives of up-to given order. More...
 
template<int DerivativeOrder>
SplineTraits< BSpline, DerivativeOrder >::DerivativeType derivatives (Scalar u, Eigen::DenseIndex order=DerivativeOrder) const
 
SplineTraits< BSpline >::BasisVectorType basisFunctions (Scalar u) const
 Computes the non-zero basis functions at the given site. More...
 
SplineTraits< BSpline >::BasisDerivativeType basisFunctionDerivatives (Scalar u, Eigen::DenseIndex order) const
 Computes the non-zero spline basis function derivatives up to given order. More...
 
template<int DerivativeOrder>
SplineTraits< BSpline, DerivativeOrder >::BasisDerivativeType basisFunctionDerivatives (Scalar u, Eigen::DenseIndex order=DerivativeOrder) const
 
Eigen::DenseIndex degree () const
 Returns the spline degree. More...
 
Eigen::DenseIndex span (Scalar u) const
 Returns the span within the knot vector in which u is falling. More...
 

Static Public Member Functions

static Eigen::DenseIndex Span (typename SplineTraits< BSpline >::Scalar u, Eigen::DenseIndex degree, const typename SplineTraits< BSpline >::KnotVectorType &knots)
 Computes the spang within the provided knot vector in which u is falling. More...
 
static BasisVectorType BasisFunctions (Scalar u, Eigen::DenseIndex degree, const KnotVectorType &knots)
 Returns the spline's non-zero basis functions. More...
 
static BasisDerivativeType BasisFunctionDerivatives (const Scalar u, const Eigen::DenseIndex order, const Eigen::DenseIndex degree, const KnotVectorType &knots)
 

Static Private Member Functions

template<typename DerivativeType >
static void BasisFunctionDerivativesImpl (const typename BSpline< _Scalar, _Dim, _Degree >::Scalar u, const Eigen::DenseIndex order, const Eigen::DenseIndex p, const typename BSpline< _Scalar, _Dim, _Degree >::KnotVectorType &U, DerivativeType &N_)
 

Private Attributes

KnotVectorType m_knots
 
ControlPointVectorType m_ctrls
 

Member Typedef Documentation

◆ BasisDerivativeType

template<typename _Scalar , int _Dim, int _Degree>
typedef SplineTraits<BSpline>::BasisDerivativeType aikido::common::BSpline< _Scalar, _Dim, _Degree >::BasisDerivativeType

The data type used to store the values of the basis function derivatives.

◆ BasisVectorType

template<typename _Scalar , int _Dim, int _Degree>
typedef SplineTraits<BSpline>::BasisVectorType aikido::common::BSpline< _Scalar, _Dim, _Degree >::BasisVectorType

The data type used to store non-zero basis functions.

◆ ControlPointVectorType

template<typename _Scalar , int _Dim, int _Degree>
typedef SplineTraits<BSpline>::ControlPointVectorType aikido::common::BSpline< _Scalar, _Dim, _Degree >::ControlPointVectorType

The data type representing the spline's control points.

◆ KnotVectorType

template<typename _Scalar , int _Dim, int _Degree>
typedef SplineTraits<BSpline>::KnotVectorType aikido::common::BSpline< _Scalar, _Dim, _Degree >::KnotVectorType

The data type used to store knot vectors.

◆ ParameterVectorType

template<typename _Scalar , int _Dim, int _Degree>
typedef SplineTraits<BSpline>::ParameterVectorType aikido::common::BSpline< _Scalar, _Dim, _Degree >::ParameterVectorType

The data type used to store parameter vectors.

◆ PointType

template<typename _Scalar , int _Dim, int _Degree>
typedef SplineTraits<BSpline>::PointType aikido::common::BSpline< _Scalar, _Dim, _Degree >::PointType

The point type the spline is representing.

◆ Scalar

template<typename _Scalar , int _Dim, int _Degree>
typedef _Scalar aikido::common::BSpline< _Scalar, _Dim, _Degree >::Scalar

The spline curve's scalar type.

Member Enumeration Documentation

◆ anonymous enum

template<typename _Scalar , int _Dim, int _Degree>
anonymous enum
Enumerator
Dimension 

The spline curve's dimension.

◆ anonymous enum

template<typename _Scalar , int _Dim, int _Degree>
anonymous enum
Enumerator
Degree 

The spline curve's degree.

Constructor & Destructor Documentation

◆ BSpline() [1/3]

template<typename _Scalar , int _Dim, int _Degree>
aikido::common::BSpline< _Scalar, _Dim, _Degree >::BSpline ( )
inline

Creates a (constant) zero spline.

For Splines with dynamic degree, the resulting degree will be 0.

◆ BSpline() [2/3]

template<typename _Scalar , int _Dim, int _Degree>
template<typename OtherVectorType , typename OtherArrayType >
aikido::common::BSpline< _Scalar, _Dim, _Degree >::BSpline ( const OtherVectorType &  knots,
const OtherArrayType &  ctrls 
)
inline

Creates a spline from a knot vector and control points.

Parameters
knotsThe spline's knot vector.
ctrlsThe spline's control point vector.

◆ BSpline() [3/3]

template<typename _Scalar , int _Dim, int _Degree>
template<int OtherDegree>
aikido::common::BSpline< _Scalar, _Dim, _Degree >::BSpline ( const BSpline< Scalar, Dimension, OtherDegree > &  spline)
inline

Copy constructor for splines.

Parameters
splineThe input spline.

Member Function Documentation

◆ BasisFunctionDerivatives()

template<typename _Scalar , int _Dim, int _Degree>
SplineTraits< BSpline< _Scalar, _Dim, _Degree > >::BasisDerivativeType aikido::common::BSpline< _Scalar, _Dim, _Degree >::BasisFunctionDerivatives ( const Scalar  u,
const Eigen::DenseIndex  order,
const Eigen::DenseIndex  degree,
const KnotVectorType &  knots 
)
static

Parameters
degreeThe degree of the underlying spline
knotsThe underlying spline's knot vector.

◆ basisFunctionDerivatives() [1/2]

template<typename _Scalar , int _Dim, int _Degree>
SplineTraits< BSpline< _Scalar, _Dim, _Degree >, DerivativeOrder >::BasisDerivativeType aikido::common::BSpline< _Scalar, _Dim, _Degree >::basisFunctionDerivatives ( Scalar  u,
Eigen::DenseIndex  order 
) const

Computes the non-zero spline basis function derivatives up to given order.

The function computes

\begin{align*} \frac{d^i}{du^i} N_{i,p}(u), \hdots, \frac{d^i}{du^i} N_{i+p+1,p}(u) \end{align*}

with i ranging from 0 up to the specified order.

Parameters
uParameter $u \in [0;1]$ at which the non-zero basis function derivatives are computed.
orderThe order up to which the basis function derivatives are computes.

◆ basisFunctionDerivatives() [2/2]

template<typename _Scalar , int _Dim, int _Degree>
template<int DerivativeOrder>
SplineTraits<BSpline, DerivativeOrder>::BasisDerivativeType aikido::common::BSpline< _Scalar, _Dim, _Degree >::basisFunctionDerivatives ( Scalar  u,
Eigen::DenseIndex  order = DerivativeOrder 
) const

Using the template version of this function is more efficieent since temporary objects are allocated on the stack whenever this is possible.

◆ BasisFunctionDerivativesImpl()

template<typename _Scalar , int _Dim, int _Degree>
template<typename DerivativeType >
void aikido::common::BSpline< _Scalar, _Dim, _Degree >::BasisFunctionDerivativesImpl ( const typename BSpline< _Scalar, _Dim, _Degree >::Scalar  u,
const Eigen::DenseIndex  order,
const Eigen::DenseIndex  p,
const typename BSpline< _Scalar, _Dim, _Degree >::KnotVectorType &  U,
DerivativeType &  N_ 
)
staticprivate

◆ basisFunctions()

template<typename _Scalar , int _Dim, int _Degree>
SplineTraits< BSpline< _Scalar, _Dim, _Degree > >::BasisVectorType aikido::common::BSpline< _Scalar, _Dim, _Degree >::basisFunctions ( Scalar  u) const

Computes the non-zero basis functions at the given site.

Splines have local support and a point from their image is defined by exactly $p+1$ control points $P_i$ where $p$ is the spline degree.

This function computes the $p+1$ non-zero basis function values for a given parameter value $u$. It returns

\begin{align*} N_{i,p}(u), \hdots, N_{i+p+1,p}(u) \end{align*}

Parameters
uParameter $u \in [0;1]$ at which the non-zero basis functions are computed.

◆ BasisFunctions()

template<typename _Scalar , int _Dim, int _Degree>
BSpline< _Scalar, _Dim, _Degree >::BasisVectorType aikido::common::BSpline< _Scalar, _Dim, _Degree >::BasisFunctions ( Scalar  u,
Eigen::DenseIndex  degree,
const KnotVectorType &  knots 
)
static

Returns the spline's non-zero basis functions.

The function computes and returns

\begin{align*} N_{i,p}(u), \hdots, N_{i+p+1,p}(u) \end{align*}

Parameters
uThe site at which the basis functions are computed.
degreeThe degree of the underlying spline.
knotsThe underlying spline's knot vector.

◆ ctrls() [1/2]

template<typename _Scalar , int _Dim, int _Degree>
ControlPointVectorType& aikido::common::BSpline< _Scalar, _Dim, _Degree >::ctrls ( )
inline

Returns the ctrls of the underlying spline.

◆ ctrls() [2/2]

template<typename _Scalar , int _Dim, int _Degree>
const ControlPointVectorType& aikido::common::BSpline< _Scalar, _Dim, _Degree >::ctrls ( ) const
inline

Returns the ctrls of the underlying spline.

◆ degree()

template<typename _Scalar , int _Dim, int _Degree>
Eigen::DenseIndex aikido::common::BSpline< _Scalar, _Dim, _Degree >::degree

Returns the spline degree.

◆ derivatives() [1/2]

template<typename _Scalar , int _Dim, int _Degree>
SplineTraits< BSpline< _Scalar, _Dim, _Degree >, DerivativeOrder >::DerivativeType aikido::common::BSpline< _Scalar, _Dim, _Degree >::derivatives ( Scalar  u,
Eigen::DenseIndex  order 
) const

Evaluation of spline derivatives of up-to given order.

The function returns

\begin{align*} \frac{d^i}{du^i}C(u) & = \sum_{i=0}^{n} \frac{d^i}{du^i} N_{i,p}(u)P_i \end{align*}

for i ranging between 0 and order.

Parameters
uParameter $u \in [0;1]$ at which the spline derivative is evaluated.
orderThe order up to which the derivatives are computed.

◆ derivatives() [2/2]

template<typename _Scalar , int _Dim, int _Degree>
template<int DerivativeOrder>
SplineTraits<BSpline, DerivativeOrder>::DerivativeType aikido::common::BSpline< _Scalar, _Dim, _Degree >::derivatives ( Scalar  u,
Eigen::DenseIndex  order = DerivativeOrder 
) const

Using the template version of this function is more efficieent since temporary objects are allocated on the stack whenever this is possible.

◆ knots()

template<typename _Scalar , int _Dim, int _Degree>
const KnotVectorType& aikido::common::BSpline< _Scalar, _Dim, _Degree >::knots ( ) const
inline

Returns the knots of the underlying spline.

◆ operator()()

template<typename _Scalar , int _Dim, int _Degree>
BSpline< _Scalar, _Dim, _Degree >::PointType aikido::common::BSpline< _Scalar, _Dim, _Degree >::operator() ( Scalar  u) const

Returns the spline value at a given site $u$.

The function returns

\begin{align*} C(u) & = \sum_{i=0}^{n}N_{i,p}P_i \end{align*}

Parameters
uParameter $u \in [0;1]$ at which the spline is evaluated.
Returns
The spline value at the given location $u$.

◆ span()

template<typename _Scalar , int _Dim, int _Degree>
Eigen::DenseIndex aikido::common::BSpline< _Scalar, _Dim, _Degree >::span ( Scalar  u) const

Returns the span within the knot vector in which u is falling.

Parameters
uThe site for which the span is determined.

◆ Span()

template<typename _Scalar , int _Dim, int _Degree>
Eigen::DenseIndex aikido::common::BSpline< _Scalar, _Dim, _Degree >::Span ( typename SplineTraits< BSpline< _Scalar, _Dim, _Degree > >::Scalar  u,
Eigen::DenseIndex  degree,
const typename SplineTraits< BSpline< _Scalar, _Dim, _Degree > >::KnotVectorType &  knots 
)
static

Computes the spang within the provided knot vector in which u is falling.

Member Data Documentation

◆ m_ctrls

template<typename _Scalar , int _Dim, int _Degree>
ControlPointVectorType aikido::common::BSpline< _Scalar, _Dim, _Degree >::m_ctrls
private

Control points.

◆ m_knots

template<typename _Scalar , int _Dim, int _Degree>
KnotVectorType aikido::common::BSpline< _Scalar, _Dim, _Degree >::m_knots
private

Knot vector.