Created
August 28, 2020 19:38
-
-
Save theoknock/7a0b284bb29b8186ff45c732a6d69d29 to your computer and use it in GitHub Desktop.
Scales values within one range to another range
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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