mapRange function
Remaps value from the input range [fromMin, fromMax] to the output
range [toMin, toMax].
The input fraction is clamped to [0, 1] via inverseLerp, so value
outside the input range maps to the nearest output endpoint.
Example:
mapRange(5, 0, 10, 0, 100); // 50.0
Implementation
double mapRange(double value, double fromMin, double fromMax, double toMin, double toMax) {
final double t = inverseLerp(fromMin, fromMax, value);
return lerp(toMin, toMax, t);
}