remap function

double remap(
  1. double value,
  2. double start1,
  3. double stop1,
  4. double start2,
  5. double stop2,
)

This funcion is like a lerp and unlerp, but is general. Its expect a number and a range for interpolate, after the result is interpolated with a second range

Implementation

double remap(
  double value,
  double start1,
  double stop1,
  double start2,
  double stop2,
) {
  final outgoing =
      start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));

  return outgoing;
}