Created
January 15, 2015 17:44
-
-
Save LaptopHeaven/a280a94ec6f589bfc805 to your computer and use it in GitHub Desktop.
C# method to map a value to a new scale. Requires the value, the current min and max values and the new min and max values.
This file contains 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
public static double Map(double value, double fromMin, double fromMax, double toMin, double toMax) | |
{ | |
return (value - fromMin) * (toMax - toMin) / (fromMax - fromMin) + toMin; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment