Skip to content

Instantly share code, notes, and snippets.

@RedForty
Last active November 19, 2020 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedForty/5ef9e74b3e632e84a5cca1273c44440f to your computer and use it in GitHub Desktop.
Save RedForty/5ef9e74b3e632e84a5cca1273c44440f to your computer and use it in GitHub Desktop.
Lerp, Inv_lerp, remap
# Thank you Freya Holmer | Neat Corp
# https://youtu.be/NzjF1pdlK7Y
def lerp(a, b, t):
return ((1.0 - t) * a + b * t)
def inv_lerp(a, b, v):
return ((v - a) / (b - a))
def remap(iMin, iMax, oMin, oMax, v):
t = inv_lerp(iMin, iMax, v)
return lerp(oMin, oMax, t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment