Last active
May 12, 2020 16:25
-
-
Save remyhunt/7c4266a0503eb44860d7b52a80b3b0b2 to your computer and use it in GitHub Desktop.
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
/* a simple but elegant map function that I pretty much find myself needing. */ | |
function map(x, in_min, in_max, out_min, out_max) { | |
return (x - 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