Created
May 6, 2015 11:09
-
-
Save Kodagrux/5b39358d812c0fd8eaf4 to your computer and use it in GitHub Desktop.
reMap-function for Python
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, maxInput, minInput, maxOutput, minOutput): | |
value = maxInput if value > maxInput else value | |
value = minInput if value < minInput else value | |
inputSpan = maxInput - minInput | |
outputSpan = maxOutput - minOutput | |
scaledThrust = float(value - minInput) / float(inputSpan) | |
return minOutput + (scaledThrust * outputSpan) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment