curve_abc.h 3.46 KB
Newer Older
1
/**
Guilhem Saurel's avatar
Guilhem Saurel committed
2
3
4
5
6
7
8
9
 * \file curve_abc.h
 * \brief interface for a Curve of arbitrary dimension.
 * \author Steve T.
 * \version 0.1
 * \date 06/17/2013
 *
 * Interface for a curve
 */
10

11
12
#ifndef _STRUCT_CURVE_ABC
#define _STRUCT_CURVE_ABC
13
14

#include "MathDefs.h"
15
16
#include "serialization/archive.hpp"
#include "serialization/eigen-matrix.hpp"
17
#include <boost/serialization/shared_ptr.hpp>
18
#include <boost/smart_ptr/shared_ptr.hpp>
19

20
#include <functional>
21

Guilhem Saurel's avatar
Format    
Guilhem Saurel committed
22
namespace curves {
Guilhem Saurel's avatar
Guilhem Saurel committed
23
24
25
/// \struct curve_abc.
/// \brief Represents a curve of dimension Dim.
/// If value of parameter Safe is false, no verification is made on the evaluation of the curve.
Guilhem Saurel's avatar
Format    
Guilhem Saurel committed
26
27
28
29
30
31
template <typename Time = double, typename Numeric = Time, bool Safe = false,
          typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename Point_derivate = Point>
struct curve_abc : std::unary_function<Time, Point>, public serialization::Serializable {
  typedef Point point_t;
  typedef Point_derivate point_derivate_t;
  typedef Time time_t;
32
33
  typedef curve_abc<Time, Numeric, Safe, point_t,point_derivate_t> curve_t; // parent class
  typedef boost::shared_ptr<curve_t> curve_ptr_t;
34

Guilhem Saurel's avatar
Guilhem Saurel committed
35
36
37
38
  /* Constructors - destructors */
 public:
  /// \brief Constructor.
  curve_abc() {}
39

Guilhem Saurel's avatar
Guilhem Saurel committed
40
41
42
  /// \brief Destructor.
  virtual ~curve_abc() {}
  /* Constructors - destructors */
43

Guilhem Saurel's avatar
Guilhem Saurel committed
44
45
46
47
48
  /*Operations*/
  ///  \brief Evaluation of the cubic spline at time t.
  ///  \param t : time when to evaluate the spine
  ///  \return \f$x(t)\f$, point corresponding on curve at time t.
  virtual point_t operator()(const time_t t) const = 0;
t steve's avatar
t steve committed
49

50
51
52

  ///  \brief Compute the derived curve at order N.
  ///  \param order : order of derivative.
53
54
  ///  \return A pointer to \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
  virtual curve_t* compute_derivate_ptr(const std::size_t order) const = 0;
55

Guilhem Saurel's avatar
Guilhem Saurel committed
56
57
58
59
  /// \brief Evaluate the derivative of order N of curve at time t.
  /// \param t : time when to evaluate the spline.
  /// \param order : order of derivative.
  /// \return \f$\frac{d^Nx(t)}{dt^N}\f$, point corresponding on derivative curve of order N at time t.
60
61
  virtual point_derivate_t derivate(const time_t t, const std::size_t order) const = 0;

62
63
64
65
66
  ///  \brief Compute the derived curve at order N.
  ///  \param order : order of derivative.
  ///  \return \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
  //virtual curve_t* compute_derivate(const std::size_t order) const = 0 ;

Guilhem Saurel's avatar
Guilhem Saurel committed
67
  /*Operations*/
68

Guilhem Saurel's avatar
Guilhem Saurel committed
69
70
71
72
73
74
75
76
77
78
  /*Helpers*/
  /// \brief Get dimension of curve.
  /// \return dimension of curve.
  virtual std::size_t dim() const = 0;
  /// \brief Get the minimum time for which the curve is defined.
  /// \return \f$t_{min}\f$, lower bound of time range.
  virtual time_t min() const = 0;
  /// \brief Get the maximum time for which the curve is defined.
  /// \return \f$t_{max}\f$, upper bound of time range.
  virtual time_t max() const = 0;
79
80
81
82
  /// \brief Get the degree of the curve.
  /// \return \f$degree\f$, the degree of the curve.
  virtual std::size_t  degree() const =0;

Guilhem Saurel's avatar
Guilhem Saurel committed
83
84
  std::pair<time_t, time_t> timeRange() { return std::make_pair(min(), max()); }
  /*Helpers*/
85

Guilhem Saurel's avatar
Guilhem Saurel committed
86
87
88
  // Serialization of the class
  friend class boost::serialization::access;
  template <class Archive>
Pierre Fernbach's avatar
Pierre Fernbach committed
89
  void serialize(Archive& /*ar*/, const unsigned int version) {
Guilhem Saurel's avatar
Guilhem Saurel committed
90
91
92
93
94
    if (version) {
      // Do something depending on version ?
    }
  }
};
95
BOOST_SERIALIZATION_ASSUME_ABSTRACT(curve_abc)
Guilhem Saurel's avatar
Guilhem Saurel committed
96
97
}  // namespace curves
#endif  //_STRUCT_CURVE_ABC