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

◆ normalize()

template<typename T >
constexpr T MayaFlux::Kinesis::normalize ( x,
lo,
hi 
)
constexprnoexcept

Normalize x in [lo, hi] to [0, 1], unclamped.

Distinct from Kinesis::Discrete::normalize, which operates in-place on a span and computes its own min/max. This is the scalar equivalent.

Degenerate range (lo == hi) returns 0.

Definition at line 46 of file Scalar.hpp.

47{
48 const T range = hi - lo;
49 if (range == T { 0 })
50 return T { 0 };
51 return (x - lo) / range;
52}