-
-
Save satishgoda/1224b699ee0d2868e8214b1b579eac72 to your computer and use it in GitHub Desktop.
reMap-function for Python
This file contains hidden or 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