Created
August 9, 2023 12:52
-
-
Save quidmonkey/19f407d6e9ee2660a5eb78baf4ce8b1c to your computer and use it in GitHub Desktop.
Map a Number from One Value System to Another
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
Number.prototype.map = (istart, istop, ostart, ostop) => { | |
return ostart + (ostop - ostart) * ((this - istart) / (istop - istart)); | |
}; | |
const map = (value, istart, istop, ostart, ostop) => { | |
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment