In many situations, especially when it concerns animating things, it's useful to have easing functions that take a linearly-changing parameter t, which gets values from 0.0 to 1.0, and return a curve (that likewise starts from 0.0 and ends in 1.0, but does something else than increase linearly). One useful such easing function is one that starts slow and accelerates up to t=0.5, and then decelerates and ends slow in t=1.0. (This is useful eg. when animating an object on screen, to have it perform that kind of smooth accelerating/decelerating motion instead of moving at constant speed.)
One way of creating such a function is to make it polynomial, like this:
double easeInOut(double t, double exponent)
{
if(t < 0.5) return pow(2 * t, exponent) * 0.5;
else return 1 - pow(2 * (1 - t), exponent) * 0.5;
}
What this does is that when t < 0.5, it's scaled to the range 0-1, the exponent is applied to it, and then scaled back to the range 0-0.5. And when t >= 0.5, the same is done, but mirroring t about 0.5 (thus getting a mirrored curve).
This allows choosing the speed at which the acceleration/deceleration changes, so that with exponent values that are close to 1.0 the acceleration is not very pronounced, and with larger values it gets more pronounced. For example with an exponent of 2 we get this nice easing curve:
With an exponent of 4 the curve is more pronounced:
The important thing is that the curve is smooth over the entire range.
Now, what if we wanted the starting acceleration to be less pronounced than the ending deceleration? In other words, what if we wanted to use two exponents rather than one: The first exponent for the first half, and the second exponent for the second half. We can't simply plug the two exponents in the above code because the resulting curve is not smooth:
There's a visible jump in slope at t=0.5 (and this jump becomes very obvious if eg. used in an animation).
So my question is: How to get a smooth curve like this, where the starting half uses one exponent and the ending half uses another?
One possibility would be to change those 0.5 factors in the formula, so that the joint point at t=0.5 goes up or down (in this example it would have to go up). But by how much, exactly?