Skip to content

Instantly share code, notes, and snippets.

@Kodagrux
Created May 6, 2015 11:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Kodagrux/5b39358d812c0fd8eaf4 to your computer and use it in GitHub Desktop.
Save Kodagrux/5b39358d812c0fd8eaf4 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