Created
February 4, 2019 20:31
-
-
Save alpual/7e6e2601b1a14532e78e1f85dba4fe88 to your computer and use it in GitHub Desktop.
Mapping values from 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
// function to map a value from one range to another range | |
const map = (value, in_min, in_max, out_min, out_max) => { | |
return ( | |
((value - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment