curves::polynomial< Time, Numeric, Safe, Point, T_Point > Class Template Reference

Represents a polynomial of an arbitrary order defined on the interval $[t_{min}, t_{max}]$. More...

#include <curves/polynomial.h>

Inheritance diagram for curves::polynomial< Time, Numeric, Safe, Point, T_Point >:
[legend]
Collaboration diagram for curves::polynomial< Time, Numeric, Safe, Point, T_Point >:
[legend]

Public Types

typedef Point point_t
 
typedef T_Point t_point_t
 
typedef Time time_t
 
typedef Numeric num_t
 
typedef curve_abc< Time, Numeric, Safe, Point > curve_abc_t
 
typedef Eigen::MatrixXd coeff_t
 
typedef Eigen::Ref< coeff_tcoeff_t_ref
 
typedef polynomial< Time, Numeric, Safe, Point, T_Point > polynomial_t
 
typedef curve_abc_t::curve_ptr_t curve_ptr_t
 
- Public Types inherited from curves::curve_abc< Time, Numeric, Safe, Point >
typedef Point point_t
 
typedef Point point_derivate_t
 
typedef Time time_t
 
typedef Numeric num_t
 
typedef curve_abc< Time, Numeric, Safe, point_t, point_derivate_tcurve_t
 
typedef boost::shared_ptr< curve_tcurve_ptr_t
 

Public Member Functions

 polynomial ()
 Empty constructor. More...
 
 polynomial (const coeff_t &coefficients, const time_t min, const time_t max)
 Constructor. More...
 
 polynomial (const T_Point &coefficients, const time_t min, const time_t max)
 Constructor. More...
 
template<typename In >
 polynomial (In zeroOrderCoefficient, In out, const time_t min, const time_t max)
 Constructor. More...
 
 polynomial (const Point &init, const Point &end, const time_t min, const time_t max)
 Constructor from boundary condition with C0 : create a polynomial that connect exactly init and end (order 1) More...
 
 polynomial (const Point &init, const Point &d_init, const Point &end, const Point &d_end, const time_t min, const time_t max)
 Constructor from boundary condition with C1 : create a polynomial that connect exactly init and end and thier first order derivatives(order 3) More...
 
 polynomial (const Point &init, const Point &d_init, const Point &dd_init, const Point &end, const Point &d_end, const Point &dd_end, const time_t min, const time_t max)
 Constructor from boundary condition with C2 : create a polynomial that connect exactly init and end and thier first and second order derivatives(order 5) More...
 
 ~polynomial ()
 Destructor. More...
 
 polynomial (const polynomial &other)
 
virtual point_t operator() (const time_t t) const
 Evaluation of the cubic spline at time t using horner's scheme. More...
 
bool isApprox (const polynomial_t &other, const Numeric prec=Eigen::NumTraits< Numeric >::dummy_precision()) const
 isApprox check if other and *this are approximately equals. More...
 
virtual bool isApprox (const curve_abc_t *other, const Numeric prec=Eigen::NumTraits< Numeric >::dummy_precision()) const
 
virtual bool operator== (const polynomial_t &other) const
 
virtual bool operator!= (const polynomial_t &other) const
 
virtual point_t derivate (const time_t t, const std::size_t order) const
 Evaluation of the derivative of order N of spline at time t. More...
 
polynomial_t compute_derivate (const std::size_t order) const
 
polynomial_tcompute_derivate_ptr (const std::size_t order) const
 Compute the derived curve at order N. More...
 
Eigen::MatrixXd coeff () const
 
point_t coeffAtDegree (const std::size_t degree) const
 
virtual std::size_t dim () const
 Get dimension of curve. More...
 
virtual num_t min () const
 Get the minimum time for which the curve is defined. More...
 
virtual num_t max () const
 Get the maximum time for which the curve is defined. More...
 
virtual std::size_t degree () const
 Get the degree of the curve. More...
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
- Public Member Functions inherited from curves::curve_abc< Time, Numeric, Safe, Point >
 curve_abc ()
 Constructor. More...
 
virtual ~curve_abc ()
 Destructor. More...
 
bool isEquivalent (const curve_t *other, const Numeric prec=Eigen::NumTraits< Numeric >::dummy_precision(), const size_t order=5) const
 isEquivalent check if other and *this are approximately equal by values, given a precision treshold. More...
 
virtual bool isApprox (const curve_t *other, const Numeric prec=Eigen::NumTraits< Numeric >::dummy_precision()) const=0
 isApprox check if other and *this are approximately equals given a precision treshold Only two curves of the same class can be approximately equals, for comparison between different type of curves see isEquivalent. More...
 
std::pair< time_t, time_ttimeRange ()
 
void serialize (Archive &, const unsigned int version)
 

Public Attributes

std::size_t dim_
 
coeff_t coefficients_
 
std::size_t degree_
 
time_t T_min_
 
time_t T_max_
 

Friends

class boost::serialization::access
 

Detailed Description

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
class curves::polynomial< Time, Numeric, Safe, Point, T_Point >

Represents a polynomial of an arbitrary order defined on the interval $[t_{min}, t_{max}]$.

It follows the equation :
$ x(t) = a + b(t - t_{min}) + ... + d(t - t_{min})^N $
where N is the order and $ t \in [t_{min}, t_{max}] $.

Member Typedef Documentation

◆ coeff_t

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
typedef Eigen::MatrixXd curves::polynomial< Time, Numeric, Safe, Point, T_Point >::coeff_t

◆ coeff_t_ref

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
typedef Eigen::Ref<coeff_t> curves::polynomial< Time, Numeric, Safe, Point, T_Point >::coeff_t_ref

◆ curve_abc_t

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
typedef curve_abc<Time, Numeric, Safe, Point> curves::polynomial< Time, Numeric, Safe, Point, T_Point >::curve_abc_t

◆ curve_ptr_t

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
typedef curve_abc_t::curve_ptr_t curves::polynomial< Time, Numeric, Safe, Point, T_Point >::curve_ptr_t

◆ num_t

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
typedef Numeric curves::polynomial< Time, Numeric, Safe, Point, T_Point >::num_t

◆ point_t

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
typedef Point curves::polynomial< Time, Numeric, Safe, Point, T_Point >::point_t

◆ polynomial_t

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
typedef polynomial<Time, Numeric, Safe, Point, T_Point> curves::polynomial< Time, Numeric, Safe, Point, T_Point >::polynomial_t

◆ t_point_t

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
typedef T_Point curves::polynomial< Time, Numeric, Safe, Point, T_Point >::t_point_t

◆ time_t

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
typedef Time curves::polynomial< Time, Numeric, Safe, Point, T_Point >::time_t

Constructor & Destructor Documentation

◆ polynomial() [1/8]

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
curves::polynomial< Time, Numeric, Safe, Point, T_Point >::polynomial ( )
inline

Empty constructor.

Curve obtained this way can not perform other class functions.

◆ polynomial() [2/8]

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
curves::polynomial< Time, Numeric, Safe, Point, T_Point >::polynomial ( const coeff_t coefficients,
const time_t  min,
const time_t  max 
)
inline

Constructor.

Parameters
coefficients: a reference to an Eigen matrix where each column is a coefficient, from the zero order coefficient, up to the highest order. Spline order is given by the number of the columns -1.
min: LOWER bound on interval definition of the curve.
max: UPPER bound on interval definition of the curve.

◆ polynomial() [3/8]

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
curves::polynomial< Time, Numeric, Safe, Point, T_Point >::polynomial ( const T_Point &  coefficients,
const time_t  min,
const time_t  max 
)
inline

Constructor.

Parameters
coefficients: a container containing all coefficients of the spline, starting with the zero order coefficient, up to the highest order. Spline order is given by the size of the coefficients.
min: LOWER bound on interval definition of the spline.
max: UPPER bound on interval definition of the spline.

◆ polynomial() [4/8]

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
template<typename In >
curves::polynomial< Time, Numeric, Safe, Point, T_Point >::polynomial ( In  zeroOrderCoefficient,
In  out,
const time_t  min,
const time_t  max 
)
inline

Constructor.

Parameters
zeroOrderCoefficient: an iterator pointing to the first element of a structure containing the coefficients it corresponds to the zero degree coefficient.
out: an iterator pointing to the last element of a structure ofcoefficients.
min: LOWER bound on interval definition of the spline.
max: UPPER bound on interval definition of the spline.

◆ polynomial() [5/8]

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
curves::polynomial< Time, Numeric, Safe, Point, T_Point >::polynomial ( const Point &  init,
const Point &  end,
const time_t  min,
const time_t  max 
)
inline

Constructor from boundary condition with C0 : create a polynomial that connect exactly init and end (order 1)

Parameters
initthe initial point of the curve
endthe final point of the curve
min: LOWER bound on interval definition of the spline.
max: UPPER bound on interval definition of the spline.

References curves::polynomial< Time, Numeric, Safe, Point, T_Point >::coefficients_, curves::polynomial< Time, Numeric, Safe, Point, T_Point >::T_max_, and curves::polynomial< Time, Numeric, Safe, Point, T_Point >::T_min_.

◆ polynomial() [6/8]

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
curves::polynomial< Time, Numeric, Safe, Point, T_Point >::polynomial ( const Point &  init,
const Point &  d_init,
const Point &  end,
const Point &  d_end,
const time_t  min,
const time_t  max 
)
inline

Constructor from boundary condition with C1 : create a polynomial that connect exactly init and end and thier first order derivatives(order 3)

Parameters
initthe initial point of the curve
d_initthe initial value of the derivative of the curve
endthe final point of the curve
d_endthe final value of the derivative of the curve
min: LOWER bound on interval definition of the spline.
max: UPPER bound on interval definition of the spline.

References curves::polynomial< Time, Numeric, Safe, Point, T_Point >::coefficients_, curves::polynomial< Time, Numeric, Safe, Point, T_Point >::degree_, curves::polynomial< Time, Numeric, Safe, Point, T_Point >::dim_, curves::polynomial< Time, Numeric, Safe, Point, T_Point >::min(), curves::polynomial< Time, Numeric, Safe, Point, T_Point >::T_max_, and curves::polynomial< Time, Numeric, Safe, Point, T_Point >::T_min_.

◆ polynomial() [7/8]

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
curves::polynomial< Time, Numeric, Safe, Point, T_Point >::polynomial ( const Point &  init,
const Point &  d_init,
const Point &  dd_init,
const Point &  end,
const Point &  d_end,
const Point &  dd_end,
const time_t  min,
const time_t  max 
)
inline

Constructor from boundary condition with C2 : create a polynomial that connect exactly init and end and thier first and second order derivatives(order 5)

Parameters
initthe initial point of the curve
d_initthe initial value of the derivative of the curve
d_initthe initial value of the second derivative of the curve
endthe final point of the curve
d_endthe final value of the derivative of the curve
d_endthe final value of the second derivative of the curve
min: LOWER bound on interval definition of the spline.
max: UPPER bound on interval definition of the spline.

References curves::polynomial< Time, Numeric, Safe, Point, T_Point >::coefficients_, curves::polynomial< Time, Numeric, Safe, Point, T_Point >::degree_, curves::polynomial< Time, Numeric, Safe, Point, T_Point >::dim_, curves::polynomial< Time, Numeric, Safe, Point, T_Point >::min(), curves::polynomial< Time, Numeric, Safe, Point, T_Point >::T_max_, and curves::polynomial< Time, Numeric, Safe, Point, T_Point >::T_min_.

◆ ~polynomial()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
curves::polynomial< Time, Numeric, Safe, Point, T_Point >::~polynomial ( )
inline

Destructor.

◆ polynomial() [8/8]

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
curves::polynomial< Time, Numeric, Safe, Point, T_Point >::polynomial ( const polynomial< Time, Numeric, Safe, Point, T_Point > &  other)
inline

Member Function Documentation

◆ coeff()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
Eigen::MatrixXd curves::polynomial< Time, Numeric, Safe, Point, T_Point >::coeff ( ) const
inline

◆ coeffAtDegree()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
point_t curves::polynomial< Time, Numeric, Safe, Point, T_Point >::coeffAtDegree ( const std::size_t  degree) const
inline

◆ compute_derivate()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
polynomial_t curves::polynomial< Time, Numeric, Safe, Point, T_Point >::compute_derivate ( const std::size_t  order) const
inline

◆ compute_derivate_ptr()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
polynomial_t* curves::polynomial< Time, Numeric, Safe, Point, T_Point >::compute_derivate_ptr ( const std::size_t  order) const
inlinevirtual

Compute the derived curve at order N.

Parameters
order: order of derivative.
Returns
A pointer to $\frac{d^Nx(t)}{dt^N}$ derivative order N of the curve.

Implements curves::curve_abc< Time, Numeric, Safe, Point >.

References curves::polynomial< Time, Numeric, Safe, Point, T_Point >::compute_derivate().

◆ degree()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
virtual std::size_t curves::polynomial< Time, Numeric, Safe, Point, T_Point >::degree ( ) const
inlinevirtual

◆ derivate()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
virtual point_t curves::polynomial< Time, Numeric, Safe, Point, T_Point >::derivate ( const time_t  t,
const std::size_t  order 
) const
inlinevirtual

◆ dim()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
virtual std::size_t curves::polynomial< Time, Numeric, Safe, Point, T_Point >::dim ( ) const
inlinevirtual

◆ isApprox() [1/2]

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
bool curves::polynomial< Time, Numeric, Safe, Point, T_Point >::isApprox ( const polynomial_t other,
const Numeric  prec = Eigen::NumTraits<Numeric>::dummy_precision() 
) const
inline

◆ isApprox() [2/2]

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
virtual bool curves::polynomial< Time, Numeric, Safe, Point, T_Point >::isApprox ( const curve_abc_t other,
const Numeric  prec = Eigen::NumTraits<Numeric>::dummy_precision() 
) const
inlinevirtual

◆ max()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
virtual num_t curves::polynomial< Time, Numeric, Safe, Point, T_Point >::max ( ) const
inlinevirtual

Get the maximum time for which the curve is defined.

Returns
$t_{max}$ upper bound of time range.

Implements curves::curve_abc< Time, Numeric, Safe, Point >.

References curves::polynomial< Time, Numeric, Safe, Point, T_Point >::T_max_.

Referenced by curves::polynomial< Time, Numeric, Safe, Point, T_Point >::isApprox().

◆ min()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
virtual num_t curves::polynomial< Time, Numeric, Safe, Point, T_Point >::min ( ) const
inlinevirtual

◆ operator!=()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
virtual bool curves::polynomial< Time, Numeric, Safe, Point, T_Point >::operator!= ( const polynomial_t other) const
inlinevirtual

◆ operator()()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
virtual point_t curves::polynomial< Time, Numeric, Safe, Point, T_Point >::operator() ( const time_t  t) const
inlinevirtual

◆ operator==()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
virtual bool curves::polynomial< Time, Numeric, Safe, Point, T_Point >::operator== ( const polynomial_t other) const
inlinevirtual

◆ serialize()

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
template<class Archive >
void curves::polynomial< Time, Numeric, Safe, Point, T_Point >::serialize ( Archive &  ar,
const unsigned int  version 
)
inline

Friends And Related Function Documentation

◆ boost::serialization::access

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
friend class boost::serialization::access
friend

Member Data Documentation

◆ coefficients_

◆ degree_

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
std::size_t curves::polynomial< Time, Numeric, Safe, Point, T_Point >::degree_

◆ dim_

template<typename Time = double, typename Numeric = Time, bool Safe = false, typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename T_Point = std::vector<Point, Eigen::aligned_allocator<Point> >>
std::size_t curves::polynomial< Time, Numeric, Safe, Point, T_Point >::dim_

◆ T_max_

◆ T_min_