interpolationFraction function
The normalized position of t between finite, strictly increasing a and
b. Scaling is necessary when the mathematical span is finite but cannot be
represented as an f64, for example -1e308..1e308.
Implementation
double interpolationFraction(double t, double a, double b) {
final span = b - a;
if (span.isFinite) return (t - a) / span;
final scale = a.abs() > b.abs() ? a.abs() : b.abs();
return ((t / scale) - (a / scale)) / ((b / scale) - (a / scale));
}