Expand description
Cyclic-distance helpers for closed-loop line topologies. Cyclic-distance helpers for closed-loop topologies.
These helpers operate on positions along a one-dimensional axis that
wraps modulo circumference. They are the foundation that
LineKind::Loop consumers — movement
physics, ETA math, headway clamping — build on.
All helpers treat any of the following as degenerate and return safe
values (typically 0.0 or the input unchanged) rather than panicking
or propagating NaN:
circumference <= 0.0- non-finite
circumference(includingNaNand±∞) - non-finite position arguments
Construction-time validation is responsible for rejecting such
configurations before they reach these helpers; the defensive returns
exist so a misconfigured run degrades gracefully rather than producing
NaN cascades through ETA / dispatch math.
Functions§
- cyclic_
distance - Shortest unsigned cyclic distance between
aandbalong a loop. - forward_
distance - Forward (one-way) cyclic distance from
fromtotoalong a loop. - wrap_
position - Normalize a position into
[0, circumference).