Created
May 16, 2017 12:01
-
-
Save kiranmaya/a859f25f042dd58f36f7abd85d134f72 to your computer and use it in GitHub Desktop.
convert from one range to another equivalent 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
float extension | |
public static float Remap(this float value, float from1, float to1, float from2, float to2,bool isClamped= false) | |
{ | |
if(isClamped) | |
{ | |
value = Mathf.Clamp(value,from1,to1); | |
} | |
return (value - from1) / (to1 - from1) * (to2 - from2) + from2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment