Created
October 28, 2016 02:25
-
-
Save anabelle2001/28e9dc658e2c14f1ab11fa77ecc1ab87 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
// Math normalize - By Beau Vandenburgh (MIT Licensed) | |
Math.normalize = function(value, min, max) { //converts range from min - max to 0 - 1 | |
* return (value - min) / (max - min) | |
} | |
Math.map = function(value, minin, maxin, minout, maxout) { //convers value from range minin,maxin to range minout,maxout | |
return Math.denormalize(Math.normalize(value, minin, maxin), minout, maxout); | |
} | |
Math.denormalize = function(value, start, stop) { //converts range from 0 - 1 to start - stop | |
return value * (stop - start) + start; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment