Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save satishgoda/1224b699ee0d2868e8214b1b579eac72 to your computer and use it in GitHub Desktop.
Save satishgoda/1224b699ee0d2868e8214b1b579eac72 to your computer and use it in GitHub Desktop.
reMap-function for Python
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