28 auto comp = [](
const Coord& a,
const Coord& b) {
return a.
t < b.t; };
30 const auto iter = std::ranges::lower_bound(_coords, coord, comp);
31 _coords.insert(iter, coord);
39 LOG(Level::FATAL,
"Finalize not called before GetPosition");
40 throw PathException(
"Finalize not called before GetPosition");
63 LOG(Level::FATAL,
"Finalize not called before GetVelocity");
64 throw PathException(
"Finalize not called before GetVelocity");
79 auto xrp = std::ranges::upper_bound(_coords, t, {}, &
Coord::t);
80 size_t idx = std::distance(_coords.begin(), xrp);
85 if (idx >= _coords.size())
86 idx = _coords.size() - 1;
91 const auto& p1 = _coords[idx - 1];
92 const auto& p2 = _coords[idx];
98 return (p2.pos - p1.pos) / dt;
103 auto xrp = std::ranges::upper_bound(_coords, t, {}, &
Coord::t);
105 if (xrp == _coords.begin())
107 else if (xrp == _coords.end())
108 xri = _coords.size() - 1;
110 xri = std::distance(_coords.begin(), xrp);
112 if (xri < 1 || xri >= _coords.size())
115 size_t xli = xri - 1;
117 const RealType h = _coords[xri].t - _coords[xli].t;
121 const RealType a = (_coords[xri].t - t) / h;
122 const RealType b = (t - _coords[xli].t) / h;
132 const RealType dc = -h / 6.0 * (3.0 * a * a - 1.0);
133 const RealType dd_coeff = h / 6.0 * (3.0 * b * b - 1.0);
135 return _coords[xli].pos * da + _coords[xri].pos * db + _dd[xli].pos * dc + _dd[xri].pos * dd_coeff;
151 finalizeCubic<Coord>(_coords, _dd);
Exception class for handling path-related errors.
Vec3 getPosition(RealType t) const
Retrieves the position at a given time along the path.
void setInterp(InterpType settype) noexcept
Changes the interpolation type.
InterpType
Types of interpolation supported by the Path class.
Vec3 getVelocity(RealType t) const
Retrieves the velocity at a given time along the path.
void addCoord(const Coord &coord) noexcept
Adds a coordinate to the path.
void finalize()
Finalizes the path, preparing it for interpolation.
A class representing a vector in rectangular coordinates.
double RealType
Type for real numbers.
constexpr RealType EPSILON
Machine epsilon for real numbers.
Coordinate and rotation structure operations.
Classes and operations for 3D geometry.
Header file for the logging system.
Provides the definition and functionality of the Path class for handling coordinate-based paths with ...
Utility functions for path interpolation and exception handling.
void getPositionLinear(RealType t, T &coord, const std::vector< T > &coords)
Performs linear interpolation between coordinate points.
void getPositionStatic(T &coord, const std::vector< T > &coords)
Interpolates a static position from a list of coordinates.
void getPositionCubic(RealType t, T &coord, const std::vector< T > &coords, const std::vector< T > &dd)
Performs cubic spline interpolation between coordinate points.
Represents a position in 3D space with an associated time.