65 Cubic(
const std::vector<
Pose<D>> &waypoints) : m_waypoints{waypoints} {
66 std::sort(m_waypoints.begin(), m_waypoints.end(),
68 return a.getTime() < b.getTime();
77 : m_waypoints{other.m_waypoints}, m_spl{other.m_spl} {}
87 m_waypoints = other.m_waypoints;
115 if (m_waypoints.size() == 0) {
119 return m_waypoints[0].getTime();
132 if (m_waypoints.size() == 0) {
136 return m_waypoints[m_waypoints.size() - 1].getTime();
155 if (m_waypoints.size() < 2) {
159 return m_spl.splpos(t);
176 if (m_waypoints.size() < 2) {
180 return m_spl.splvel(t);
197 if (m_waypoints.size() < 2) {
201 return m_spl.splacc(t);
216 double getLength(
const double timeStep)
const override {
219 if (m_waypoints.size() < 2) {
225 while (time <= timeEnd) {
227 auto speed = magn(vel);
228 res += speed * timeStep;
237 std::vector<Pose<D>> m_waypoints;
Abstract base class for interpolating splines.
Definition: base_spline.hpp:20
Spline vector calculator.
Definition: cubic_vec.hpp:25
A natural cubic spline.
Definition: cubic.hpp:44
double getLowestTime() const override
Gets the lower bound of the domain of the piecewise spline function, which is the first time (lowest ...
Definition: cubic.hpp:114
Cubic(const std::vector< Pose< D >> &waypoints)
Constructor.
Definition: cubic.hpp:65
~Cubic() override=default
Destructor.
Vector< D > getAcc(const double t) const override
Gets acceleration of the function at a certain time.
Definition: cubic.hpp:195
double getHighestTime() const override
Gets the upper bound of the domain of the piecewise spline function, which is the first time (lowest ...
Definition: cubic.hpp:131
Cubic()=default
Default constructor.
double getLength(const double timeStep) const override
Gets arc length.
Definition: cubic.hpp:216
Vector< D > getPos(const double t) const override
Gets position at a certain time.
Definition: cubic.hpp:153
Cubic< D > & operator=(const Cubic< D > &other)
Assignment operator.
Definition: cubic.hpp:82
std::vector< Pose< D > > getAllWaypoints() const
Gets a list of all waypoints.
Definition: cubic.hpp:103
Cubic(const Cubic< D > &other)
Copy constructor.
Definition: cubic.hpp:76
Vector< D > getVel(const double t) const override
Gets velocity at a certain time.
Definition: cubic.hpp:174
A pose object.
Definition: pose.hpp:23
A base vector representation.
Definition: simplevectors.hpp:63