asge::math::CatmullRomSpline
A piecewise Catmull-Rom spline through a list of waypoints, with each segment pre-sampled into an arc-length table so points and tangents can be looked up either by a normalized [0, 1] curve parameter or by actual distance travelled along the curve.
#include <CatmullRomSpline.hpp>Private Attributes
Private Member Functions
Maps a normalized spline parameter inTime in [0, 1] to the segment it falls in and the local Hermite parameter within it.
Maps inDistance (clamped to [0, Length()]) to the segment it falls in and the local Hermite parameter within it, via that segment's arc-length table — the distance-based counterpart to LocateSegment().
Shared by PointAtDistance() and TimeAtDistance().
Public Member Functions
CatmullRomSpline()=defaultexplicit CatmullRomSpline(std::vector< Float2 > inWp, std::size_t inResolution=32)Builds the spline through inWp, precomputing each segment's arc-length table with inResolution samples.
Splines with fewer than two waypoints have no segments and evaluate to a zero point.
CatmullRomSpline(CatmullRomSpline const &)=defaultCatmullRomSpline(CatmullRomSpline &&)=defaultCatmullRomSpline & operator=(CatmullRomSpline const &)=defaultCatmullRomSpline & operator=(CatmullRomSpline &&)=default~CatmullRomSpline()=defaultstd::vector< Segment > const & Segments() const noexceptReturns the spline's precomputed segments, in order.
Returns the waypoints the spline was constructed from.
bool HasSegments() const noexceptCheck if the spline has segments in it.
float Length() const noexceptReturns the total arc length of the spline.
Returns the point at normalized parameter inTime, clamped to [0, 1] and distributed evenly across segments (not arc-length corrected).
Returns the point at inDistance travelled along the curve, clamped to [0, Length()], using each segment's arc-length table.
Returns the normalized tangent direction at normalized parameter inTime.
float TimeAtDistance(float inDistance) const noexceptReturns the normalized [0, 1] parameter TangentAt()/PointAt() expect for the point inDistance (clamped to [0, Length()]) along the curve — the inverse of the distribution PointAt() walks, so PointAt(TimeAtDistance(d)) matches PointAtDistance(d).
Returns 0 for a spline with no segments.