in agdk/agde/Teapot/GameEngine/Interpolator.cpp [82:150]
float Interpolator::GetFormula(const INTERPOLATOR_TYPE type, const float t,
const float b, const float d, const float c) {
float t1;
switch (type) {
case INTERPOLATOR_TYPE_LINEAR:
// simple linear interpolation - no easing
return (c * t / d + b);
case INTERPOLATOR_TYPE_EASEINQUAD:
// quadratic (t^2) easing in - accelerating from zero velocity
t1 = t / d;
return (c * t1 * t1 + b);
case INTERPOLATOR_TYPE_EASEOUTQUAD:
// quadratic (t^2) easing out - decelerating to zero velocity
t1 = t / d;
return (-c * t1 * (t1 - 2) + b);
case INTERPOLATOR_TYPE_EASEINOUTQUAD:
// quadratic easing in/out - acceleration until halfway, then deceleration
t1 = t / d / 2;
if (t1 < 1)
return (c / 2 * t1 * t1 + b);
else {
t1 = t1 - 1;
return (-c / 2 * (t1 * (t1 - 2) - 1) + b);
}
case INTERPOLATOR_TYPE_EASEINCUBIC:
// cubic easing in - accelerating from zero velocity
t1 = t / d;
return (c * t1 * t1 * t1 + b);
case INTERPOLATOR_TYPE_EASEOUTCUBIC:
// cubic easing in - accelerating from zero velocity
t1 = t / d - 1;
return (c * (t1 * t1 * t1 + 1) + b);
case INTERPOLATOR_TYPE_EASEINOUTCUBIC:
// cubic easing in - accelerating from zero velocity
t1 = t / d / 2;
if (t1 < 1)
return (c / 2 * t1 * t1 * t1 + b);
else {
t1 -= 2;
return (c / 2 * (t1 * t1 * t1 + 2) + b);
}
case INTERPOLATOR_TYPE_EASEINQUART:
// quartic easing in - accelerating from zero velocity
t1 = t / d;
return (c * t1 * t1 * t1 * t1 + b);
case INTERPOLATOR_TYPE_EASEINEXPO:
// exponential (2^t) easing in - accelerating from zero velocity
if (t == 0)
return b;
else
return (c * powf(2, (10 * (t / d - 1))) + b);
case INTERPOLATOR_TYPE_EASEOUTEXPO:
// exponential (2^t) easing out - decelerating to zero velocity
if (t == d)
return (b + c);
else
return (c * (-powf(2, -10 * t / d) + 1) + b);
default:
return 0;
}
}