Making ease-out-bounce formula have a linear start

664 Views Asked by At

I'm using a bounce ease out formula, the code for it:

https://github.com/jesusgollonet/processing-penner-easing/blob/master/src/Bounce.java#L9.

The function is copied here:

float easeOut(float t, float b, float c, float d) {
    if ((t/=d) < (1/2.75f)) {
        return c*(7.5625f*t*t) + b;
    } else if (t < (2/2.75f)) {
        return c*(7.5625f*(t-=(1.5f/2.75f))*t + .75f) + b;
    } else if (t < (2.5/2.75)) {
        return c*(7.5625f*(t-=(2.25f/2.75f))*t + .9375f) + b;
    } else {
        return c*(7.5625f*(t-=(2.625f/2.75f))*t + .984375f) + b;
    }
}

but I'm trying to get a linear start, illustrated by the red line in this image: linear start image

Might anyone know how to modify the original formula to get that?

Thanks

1

There are 1 best solutions below

0
On

Very ugly code due to those equal signs in the middle of a statement that does something else. Not that it makes physical sense (you ignore gravity before the first bounce), but all you have to do is make sure that the velocity before the first bounce is a constant. That means that the position in the first return statement is dependent on t only, not t*t. You will need to adjust the constant in the first return statement so $$c*(7.5625\rm{f}*t*t) + b=c*(NewConstant*t) + b$$ when t= (1/2.75f)