map-clip

xod/math/map-clip

Projects a number from one range to another preserving ratio. Then clips a result to the target range.
map-clip
@/map-clip
Projects a number from one range to another preserving ratio. Then clips a result to the target range.
Xnumber
The value to map and clip.
Sminnumber
Source range lower bound
Smaxnumber
Source range upper bound
Tminnumber
Target range lower bound
Tmaxnumber
Target range upper bound
map-clip
OUT
X
Smin
Smax
Tmin
Tmax
OUTnumber
The resulting mapped and clipped value of `X`.

Previously known as xod/core/map-clip-range.

Tabular tests

XSminSmaxTminTmaxOUT
001-1010-10
0.501-10100
250101010
-10010100
0.5010InfInf
0.501-InfInfNaN
Inf0101010
-Inf010100
NaN01010NaN
0.5011005
-10110010
100011000