hermite  0.0.1
hermite_unit.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <cstddef>
10 
14 
15 namespace hermite {
16 using svector::Vector;
17 
29 template <std::size_t D> class HermiteUnit : public BaseInterpol<D> {
30 public:
37  HermiteUnit() = default;
38 
47  HermiteUnit(const Vector<D> p0, const Vector<D> p1, const Vector<D> v0,
48  const Vector<D> v1)
49  : m_p0{p0}, m_p1{p1}, m_v0{v0}, m_v1{v1} {}
50 
55  : m_p0{other.m_p0}, m_p1{other.m_p1}, m_v0{other.m_v0}, m_v1{other.m_v1} {
56  }
57 
62  // check if assigning to self
63  if (this == &other) {
64  return *this;
65  }
66 
67  m_p0 = other.m_p0;
68  m_p1 = other.m_p1;
69  m_v0 = other.m_v0;
70  m_v1 = other.m_v1;
71 
72  return *this;
73  }
74 
78  ~HermiteUnit() override = default;
79 
92  Vector<D> getPos(const double t) const override {
93  Vector<D> res;
94  res = m_p0 * h00(t) + m_v0 * h10(t) + m_p1 * h01(t) + m_v1 * h11(t);
95  return res;
96  }
97 
108  Vector<D> getVel(const double t) const override {
109  Vector<D> res;
110  res = m_p0 * h00d(t) + m_v0 * h10d(t) + m_p1 * h01d(t) + m_v1 * h11d(t);
111  return res;
112  }
113 
124  Vector<D> getAcc(const double t) const override {
125  Vector<D> res;
126  res = m_p0 * h00dd(t) + m_v0 * h10dd(t) + m_p1 * h01dd(t) + m_v1 * h11dd(t);
127  return res;
128  }
129 
130 private:
131  Vector<D> m_p0;
132  Vector<D> m_p1;
133  Vector<D> m_v0;
134  Vector<D> m_v1;
135 };
136 } // namespace hermite
constexpr double h00(const double t)
First Hermite basis function.
Definition: constants.hpp:13
constexpr double h11d(const double t)
Fourth Hermite basis function first derivative.
Definition: constants.hpp:48
constexpr double h10d(const double t)
Second Hermite basis function first derivative.
Definition: constants.hpp:38
constexpr double h01dd(const double t)
Third Hermite basis function second derivative.
Definition: constants.hpp:63
constexpr double h10dd(const double t)
Second Hermite basis function second derivative.
Definition: constants.hpp:58
constexpr double h00dd(const double t)
First Hermite basis function second derivative.
Definition: constants.hpp:53
constexpr double h11(const double t)
Fourth Hermite basis function.
Definition: constants.hpp:28
constexpr double h11dd(const double t)
Fourth Hermite basis function second derivative.
Definition: constants.hpp:68
constexpr double h01(const double t)
Third Hermite basis function.
Definition: constants.hpp:23
constexpr double h10(const double t)
Second Hermite basis function.
Definition: constants.hpp:18
constexpr double h00d(const double t)
First Hermite basis function first derivative.
Definition: constants.hpp:33
constexpr double h01d(const double t)
Third Hermite basis function first derivative.
Definition: constants.hpp:43
Base class for interpolation functions.
Definition: base_interpol.hpp:23
Interpolates on the unit interval.
Definition: hermite_unit.hpp:29
~HermiteUnit() override=default
Destructor.
Vector< D > getAcc(const double t) const override
Gets acceleration of the function at a certain time.
Definition: hermite_unit.hpp:124
Vector< D > getPos(const double t) const override
Gets position at a certain time.
Definition: hermite_unit.hpp:92
HermiteUnit(const Vector< D > p0, const Vector< D > p1, const Vector< D > v0, const Vector< D > v1)
Constructor.
Definition: hermite_unit.hpp:47
Vector< D > getVel(const double t) const override
Gets velocity at a certain time.
Definition: hermite_unit.hpp:108
HermiteUnit(const HermiteUnit< D > &other)
Copy constructor.
Definition: hermite_unit.hpp:54
HermiteUnit()=default
Default constructor.
HermiteUnit< D > & operator=(const HermiteUnit< D > &other)
Assignment operator.
Definition: hermite_unit.hpp:61
A base vector representation.
Definition: simplevectors.hpp:63