I'm want to animate an object using an ease out curve, where it moves fast at time alpha = 0 and slow at alpha = 1 from position y1 to y2.

However, the object may start at an arbitrary y position with an unknown alpha, and I need it to follow the same curve regardless.

In Unreal Engine there is this relevant built-in helper function InterpEaseOut(const T& y1, const T& y2, float Alpha, float Exp), but I don't have the starting alpha value. (Note that I don't need specifically this curve formula.)

How can I solve this?


1 Answer 1


So long as y1 and y2 are distinct, you can recover alpha with an inverse lerp:

$$\begin{align} y &= (1 - \alpha) y_1 + \alpha * y_2\\ y &= y_1 + \alpha (y_2 - y_1)\\ y - y_1 &= \alpha (y_2 - y_1)\\ \frac {y - y_1 } {y_2 - y_1} = \alpha \end{align}$$

This gives us a linear measure of progress from y1 (0% = 0) to y2 (100% = 1). Note that this does not yet factor in the non-linear relationship between time and position, this is just measuring what ratio of the distance we've covered in space.

We can then apply any easing function we want to it. Let's say we use this easing formula:

$$\alpha = 1 - (1 - \frac t {\text{duration}})^n$$

We can take its inverse to recover the time value at which we would reach this value for alpha:

$$\begin{align} \alpha &= 1 - (1 - \frac t {\text{duration}})^n\\ 1 - \alpha &= (1 - \frac t {\text{duration}})^n\\ (1 - \alpha)^{\frac 1 n} &= 1 - \frac t {\text{duration}}\\ 1 - (1 - \alpha)^{\frac 1 n} &= \frac t {\text{duration}}\\ \text{duration} \cdot \left(1 - (1 - \alpha)^{\frac 1 n}\right) &= t \end{align}$$

Now you can add your time delta to t (clamp it so it does not exceed the total ease duration), and run this back through your easing formula to get the alpha value for the next position along the curve.

  • \$\begingroup\$ I don't see how the first alpha formula is correct. It's an ease out curve and not linear. If y = 0.5, y1 = 0, y2 = 1, alpha should be < 0.5, but that formula gives 0.5 \$\endgroup\$
    – Code
    Jan 5, 2023 at 17:52
  • \$\begingroup\$ Right, because the first formula is only calculating the percent progress in space, not in time. If the first formula was enough on its own, I wouldn't have written the other two thirds of the answer. 😜 The remainder of the answer covers how to introduce non-linearity in the time<->space mapping. 1. Calculate linear progress in space. 2. Reverse the ease-out non-linearity to get progress in time. 3. Advance the time by 1 step, linearly. 4. Apply the ease-out non-linearity to return to progress in space, with the increment correctly eased-out. \$\endgroup\$
    – DMGregory
    Jan 5, 2023 at 20:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .