remap
is a useful function that takes a value from an input range to an output range. Its implementation combines an inverse lerp and a lerp.
float remap(float i_min, float i_max, float o_min, float o_max, float v) {
float t = inverse_lerp(i_min, i_max, v);
return lerp(o_min, o_max, t);
}