Skip to content

Instantly share code, notes, and snippets.

@theoknock
Created August 28, 2020 19:38
Show Gist options
  • Save theoknock/7a0b284bb29b8186ff45c732a6d69d29 to your computer and use it in GitHub Desktop.
Save theoknock/7a0b284bb29b8186ff45c732a6d69d29 to your computer and use it in GitHub Desktop.
Scales values within one range to another range
double (^scale)(double, double, double, double, double) = ^double(double min_new, double max_new, double value, double min_old, double max_old)
{
double result = min_new + ((((value - min_old) * (max_new - min_new))) / (max_old - min_old));
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment