MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ wrap()

template<typename T >
T MayaFlux::Kinesis::wrap ( T  x,
T  lo,
T  hi 
)
inlinenoexcept

Wrap x into [lo, hi) with modulo semantics.

Unlike std::fmod, handles negative values and arbitrary lo correctly. Equivalent to the GLSL mod() applied after shifting by lo.

Example: wrap(-0.1F, 0.F, 1.F) -> 0.9F

Definition at line 218 of file Scalar.hpp.

219{
220 const T range = hi - lo;
221 if (range <= T { 0 })
222 return lo;
223 return x - range * std::floor((x - lo) / range);
224}

Referenced by MayaFlux::Kinesis::Discrete::modular_recurrence().

+ Here is the caller graph for this function: