3 ms·
This isn't linear interpolation, but it is a discrete approximation of a linear differential equation (note that all linear functions can be described as lerps,
by pcwalton 4y ago
This isn't linear interpolation, but it is a discrete approximation of a linear differential equation (note that all linear functions can be described as lerps, but that's uninteresting in this case):
x'(t) = 0.2(b - x(t))
where b is the final position, x is the current position as a function of time, and t is time.
Solving this linear differential equation gives us:
x(t) = b + e^(-0.2t)
which up to a change in constants is what easings.net would call easeOutExpo [1]. So the usual way you would describe this "lerp" in computer graphics would be "exponential ease-out". This solved version of the ODE also gives us a function that isn't dependent on the framerate, so in practice the direct form with the exponential function is preferable for implementation (unless you're in a very constrained environment).
[1]: https://easings.net/#easeOutExpo https://easings.net/#easeOutExpo
- turtledragonfly 4y agoGood explanation. But one thing that might not be obvious is that "b" is a moving target in the article (and in many cases where this technique is used), so using your equation, moving "b" by one unit in a given frame will also move x(t) by one unit, causing it to feel a bit faster/more aggressive. Your final equation will guarantee that you will end up at (a given closeness to) the target at a given time, wherever that target might be, and however fast it might be moving away. Using the (poorly-named) approach in the article gives you a subtly different behavior, where the easing is essentially "reset" each frame. If you "run away" from the easing object at the right speed, you can delay it reaching you for an arbitrarily long amount of time, which has a different feel, and different practical consequences depending on the context. This is demonstrated in the "Follow the mouse" example in the article.