Inverse Lerp
lerp( a, b, t ) = value
inv_lerp( a, b, value ) = t
Inverse lerp returns a number
It can be implemented as the following:
float inverse_lerp(float a, float b, float v) {
return (v - a) / (b - a);
}
A useful function based on lerp and inverse lerp is remap, which maps a value from an input range to an output range.