Last active
November 19, 2020 05:45
-
-
Save RedForty/5ef9e74b3e632e84a5cca1273c44440f to your computer and use it in GitHub Desktop.
Lerp, Inv_lerp, remap
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
# 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