hermite  0.0.1
base_spline.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <cstddef>
10 
13 
14 namespace hermite {
15 using svector::Vector;
16 
20 template <std::size_t D> class BaseSpline : public BaseInterpol<D> {
21 public:
25  virtual ~BaseSpline() = default;
26 
35  virtual double getLowestTime() const = 0;
36 
45  virtual double getHighestTime() const = 0;
46 
56  virtual Vector<D> getPos(const double t) const = 0;
57 
67  virtual Vector<D> getVel(const double t) const = 0;
68 
78  virtual Vector<D> getAcc(const double t) const = 0;
79 
92  double getMaxDistance(const double timeStep) const {
93  double res = 0.0;
94  double time = getLowestTime();
95  const double timeEnd = getHighestTime();
96 
97  while (time <= timeEnd) {
98  auto pos = getPos(time);
99  double dist = magn(pos);
100  res = std::max(res, dist);
101 
102  time += timeStep;
103  }
104 
105  return res;
106  }
107 
120  double getMaxSpeed(const double timeStep) const {
121  double res = 0.0;
122  double time = getLowestTime();
123  const double timeEnd = getHighestTime();
124 
125  while (time <= timeEnd) {
126  auto vel = getVel(time);
127  double dist = magn(vel);
128  res = std::max(res, dist);
129 
130  time += timeStep;
131  }
132 
133  return res;
134  }
135 
148  double getMaxAcceleration(const double timeStep) const {
149  double res = 0.0;
150  double time = getLowestTime();
151  const double timeEnd = getHighestTime();
152 
153  while (time <= timeEnd) {
154  auto acc = getAcc(time);
155  double dist = magn(acc);
156  res = std::max(res, dist);
157 
158  time += timeStep;
159  }
160 
161  return res;
162  }
163 
176  virtual double getLength(const double timeStep) const = 0;
177 };
178 } // namespace hermite
Base class for interpolation functions.
Definition: base_interpol.hpp:23
Abstract base class for interpolating splines.
Definition: base_spline.hpp:20
double getMaxAcceleration(const double timeStep) const
Gets maximum magnitude of acceleration.
Definition: base_spline.hpp:148
double getMaxDistance(const double timeStep) const
Gets maximum distance from origin.
Definition: base_spline.hpp:92
virtual Vector< D > getVel(const double t) const =0
Gets derivative of the function at a certain point.
virtual Vector< D > getPos(const double t) const =0
Gets value of the interpolation function at a certain point.
double getMaxSpeed(const double timeStep) const
Gets maximum speed.
Definition: base_spline.hpp:120
virtual Vector< D > getAcc(const double t) const =0
Gets second derivative of the function at a certain point.
virtual double getLowestTime() const =0
Gets the lower bound of the domain of the piecewise spline function, which is the first time (lowest ...
virtual double getHighestTime() const =0
Gets the upper bound of the domain of the piecewise spline function, which is the last time (highest ...
virtual double getLength(const double timeStep) const =0
Gets arc length.
virtual ~BaseSpline()=default
Destructor.
A base vector representation.
Definition: simplevectors.hpp:63