Created
January 24, 2018 09:36
-
-
Save PopupAsylumUK/3d286672dfb4f9402484a45bc8cb621f to your computer and use it in GitHub Desktop.
Extension function for floats to remap it from one range to another
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
public static class FloatRemapExtension { | |
public static float Remap(this float value, float min, float max, float fromMin = 0, float fromMax = 1) { | |
return ((value - fromMin) / (fromMax - fromMin)) * (max - min) + min; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment