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

◆ wrap()

template<typename T >
T MayaFlux::Kinesis::wrap ( x,
lo,
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 135 of file Scalar.hpp.

136{
137 const T range = hi - lo;
138 if (range <= T { 0 })
139 return lo;
140 return x - range * std::floor((x - lo) / range);
141}