Skip to content

Instantly share code, notes, and snippets.

@eliheuer
Created August 31, 2023 18:18
Show Gist options
  • Save eliheuer/89a8be6eabde131a2b7f0b0da3483b24 to your computer and use it in GitHub Desktop.
Save eliheuer/89a8be6eabde131a2b7f0b0da3483b24 to your computer and use it in GitHub Desktop.
vf-normalize.py
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