# Reversing an Ease? Ease-In, Ease-Out, Ease-InOut?

This topic is 2085 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm looking over some easing equations at the moment, and viewing some code, and I got the code written for all the Ease-Ins.

Is there some way I can convert Ease-Ins to Ease-Outs without using entirely new equations?
Can I implement Ease-Outs as:

float EaseOut(blah)
{
float result = EaseIn(blah);
return reverse(result);
}


How do I generically reverse a Ease?

Looking at graphs like this, every Ease-Out is just a Ease-In rotated 180 degrees. Surely there's some way to create a function that will reverse any ease?

All my eases take a value between 0.0 to 1.0, and return a result from 0.0 to 1.0. (Actually, they can be given values less than 0.0 and greater than 1.0 and can return values less than 0.0 and greater than 1.0, but the 0.0 - 1.0 is the scale).

I can't just invert the result (1.0f - result), because that'd just flip the ease upside down. It seems I need to invert the position and the result.

Does this seem correct:

float DoEaseOut(EaseFunction easeFunction, float position)
{
float result = easeFunction(1.0f - position);
return 1.0f - result;
}

I'm not at a point where I can test the code.

Another question is, Ease-InOut seems to be:

if(less than 0.5)
{
result = EaseIn()
scale result from (0.0 - 1.0) to (0.0 - 0.5)
}
else
{
result = EaseOut()
scale result from (0.0 - 1.0) to (0.5 - 1.0)
}


Is that correct? Looking at some peoples' implementations, that sort-of seems to be what they are doing for some equations, but not for others.

So if I have all my easing equations as EaseIn equations, then I can use these:

float DoEaseOut(EaseFunction easeFunction, float position)
{
float result = easeFunction(1.0f - position);
return 1.0f - result;
}

float DoEaseInOut(EaseFunction easeFunction, float position)
{
if(position < 0.5f)
{
//Do the Ease-In.
float result = easeFunction(position * 2.0f);

//Scale to (0.0 - 0.5).
return (result * 0.5f);
}
else
{
//Do the Ease-Out.
float result = DoEaseOut(easeFunction, (position * 2.0f) - 1.0f);

//Scale to (0.5 - 1.0).
return (result * 0.5f) + 0.5f;
}
}

And just pass in the desired Ease-In functions?

Edited by Servant of the Lord

##### Share on other sites

There is at least one mistake in your code, but your general ideas are correct. You should use your code to generate a few graphs and then you'll find any mistakes easily.

##### Share on other sites

I followed your advice and generated some graphs. It looks like it's working. What mistakes are you seeing in the code?

Bounce EaseIn

Bounce EaseOut

Bounce EaseInOut

##### Share on other sites

Oh, never mind. I thought you had a sign error but I was wrong.

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633312
• Total Posts
3011312
• ### Who's Online (See full list)

There are no registered users currently online

×