Created
August 31, 2023 18:18
-
-
Save eliheuer/89a8be6eabde131a2b7f0b0da3483b24 to your computer and use it in GitHub Desktop.
vf-normalize.py
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
def remap(value, inputMin, inputMax, outputMin, outputMax): | |
inputSpan = inputMax - inputMin # FIND INPUT RANGE SPAN | |
outputSpan = outputMax - outputMin # FIND OUTPUT RANGE SPAN | |
valueScaled = float(value - inputMin) / float(inputSpan) | |
return outputMin + (valueScaled * outputSpan) | |
test01 = remap(0, -100, 100, 20, 250) | |
print(test01) | |
test02 = remap(-100, -100, 100, 20, 250) | |
print(test02) | |
test03 = remap(100, -100, 100, 20, 250) | |
print(test03) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment