Created
September 29, 2021 09:41
-
-
Save lmarti17/07653d7953717f187e39f65ad4d12ff0 to your computer and use it in GitHub Desktop.
Function to interpolate a value between a min and a max value.
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
function scaleToRange( | |
num: number, | |
in_min: number, | |
in_max: number, | |
out_min: number, | |
out_max: number | |
) { | |
return ((num - 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