11#ifndef _STRUCT_CURVE_ABC
12#define _STRUCT_CURVE_ABC
14#include <boost/serialization/shared_ptr.hpp>
15#include <boost/smart_ptr/shared_ptr.hpp>
26bool isApprox(
const T a,
const T b,
const T eps = 1e-6) {
27 return fabs(a - b) < eps;
34template <
typename Time = double,
typename Numeric = Time,
bool Safe =
false,
35 typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>,
36 typename Point_derivate = Point>
68 const std::size_t order)
const = 0;
76 const std::size_t order)
const = 0;
91 const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision(),
92 const size_t order = 5)
const {
93 bool equal = ndcurves::isApprox<num_t>(
min(), other->
min()) &&
94 ndcurves::isApprox<num_t>(
max(), other->
max()) &&
104 if (!(*
this)(t).
isApprox(other->operator()(t), prec)) {
110 for (
size_t n = 1; n <= order; ++n) {
134 Eigen::NumTraits<Numeric>::dummy_precision())
const = 0;
141 virtual std::size_t
dim()
const = 0;
157 template <
class Archive>
158 void serialize(Archive& ar,
const unsigned int version) {
159 serialization::register_types<Archive>(ar, version);
165BOOST_SERIALIZATION_ASSUME_ABSTRACT(curve_abc)
169 SINGLE_ARG(
typename Time,
typename Numeric,
bool Safe,
typename Point,
170 typename Point_derivate),
#define DEFINE_CLASS_TEMPLATE_VERSION(Template, Type)
Definition: archive.hpp:27
#define SINGLE_ARG(...)
Definition: archive.hpp:23
Definition: bernstein.h:20
bool isApprox(const T a, const T b, const T eps=1e-6)
Definition: curve_abc.h:26
Represents a curve of dimension Dim. If value of parameter Safe is false, no verification is made on ...
Definition: curve_abc.h:37
Numeric num_t
Definition: curve_abc.h:41
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 equal given a precision treshold Only two curves ...
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....
Definition: curve_abc.h:89
virtual std::size_t dim() const =0
Get dimension of curve.
Time time_t
Definition: curve_abc.h:40
curve_abc< Time, Numeric, Safe, point_t, point_derivate_t > curve_t
Definition: curve_abc.h:43
virtual ~curve_abc()
Destructor.
Definition: curve_abc.h:54
boost::shared_ptr< curve_t > curve_ptr_t
Definition: curve_abc.h:46
virtual point_t operator()(const time_t t) const =0
Evaluation of the cubic spline at time t.
curve_abc()
Constructor.
Definition: curve_abc.h:51
Point_derivate point_derivate_t
Definition: curve_abc.h:39
virtual time_t min() const =0
Get the minimum time for which the curve is defined.
std::pair< time_t, time_t > timeRange()
Definition: curve_abc.h:152
curve_abc< Time, Numeric, Safe, point_derivate_t > curve_derivate_t
Definition: curve_abc.h:45
friend class boost::serialization::access
Definition: curve_abc.h:156
virtual point_derivate_t derivate(const time_t t, const std::size_t order) const =0
Evaluate the derivative of order N of curve at time t.
virtual time_t max() const =0
Get the maximum time for which the curve is defined.
void serialize(Archive &ar, const unsigned int version)
Definition: curve_abc.h:158
virtual curve_derivate_t * compute_derivate_ptr(const std::size_t order) const =0
Compute the derived curve at order N.
Point point_t
Definition: curve_abc.h:38
virtual std::size_t degree() const =0
Get the degree of the curve.
Definition: archive.hpp:41