|
static Lerp | mapRange (X iFromLow, X iFromHigh, Y iToLow, Y iToHigh) |
| Inspired by the map function in Processing language, another way to look at Lerp is to map a range of values into another range: [iFromLow, iFromHigh] -> [iToLow, iToHigh] . More...
|
|
static Y | mapValue (X iValue, X iFromLow, X iFromHigh, Y iToLow, Y iToHigh, bool iClamp=true) |
| Inspired by the map function in Processing language, another way to look at Lerp is to map a range of values into another range: [iFromLow, iFromHigh] -> [iToLow, iToHigh] . More...
|
|
template<typename TFloat, typename X, typename Y>
class pongasoft::Utils::Lerp< TFloat, X, Y >
Util class to compute linear interpolation.
Use SPLerp/DPLerp and mapValueSP/mapRangeSP (resp mapValueDP/mapRangeDP) for convenience.
Providing iX1 == iX2 will result in undefined behavior
static Lerp mapRange |
( |
X |
iFromLow, |
|
|
X |
iFromHigh, |
|
|
Y |
iToLow, |
|
|
Y |
iToHigh |
|
) |
| |
|
inlinestatic |
Inspired by the map
function in Processing language, another way to look at Lerp is to map a range of values into another range: [iFromLow, iFromHigh] -> [iToLow, iToHigh]
.
Note that low can be greater than high: for example you can map [1, -1]
to the range [0, height]
(display where 0 is at the top and height is the bottom)
static Y mapValue |
( |
X |
iValue, |
|
|
X |
iFromLow, |
|
|
X |
iFromHigh, |
|
|
Y |
iToLow, |
|
|
Y |
iToHigh, |
|
|
bool |
iClamp = true |
|
) |
| |
|
inlinestatic |
Inspired by the map
function in Processing language, another way to look at Lerp is to map a range of values into another range: [iFromLow, iFromHigh] -> [iToLow, iToHigh]
.
This function then returns the iValue
mapped from the first range into the second range. When iClamp
is set to true
, the incoming value will first be clamped to the from range. ex: