Permalink
Switch branches/tags
Nothing to show
Find file Copy path
a35b54d Nov 7, 2008
1 contributor

Users who have contributed to this file

32 lines (28 sloc) 992 Bytes
#include "Elastic.h"
float Elastic::easeIn (float t,float b , float c, float d) {
if (t==0) return b; if ((t/=d)==1) return b+c;
float p=d*.3f;
float a=c;
float s=p/4;
float postFix =a*pow(2,10*(t-=1)); // this is a fix, again, with post-increment operators
return -(postFix * sin((t*d-s)*(2*PI)/p )) + b;
}
float Elastic::easeOut(float t,float b , float c, float d) {
if (t==0) return b; if ((t/=d)==1) return b+c;
float p=d*.3f;
float a=c;
float s=p/4;
return (a*pow(2,-10*t) * sin( (t*d-s)*(2*PI)/p ) + c + b);
}
float Elastic::easeInOut(float t,float b , float c, float d) {
if (t==0) return b; if ((t/=d/2)==2) return b+c;
float p=d*(.3f*1.5f);
float a=c;
float s=p/4;
if (t < 1) {
float postFix =a*pow(2,10*(t-=1)); // postIncrement is evil
return -.5f*(postFix* sin( (t*d-s)*(2*PI)/p )) + b;
}
float postFix = a*pow(2,-10*(t-=1)); // postIncrement is evil
return postFix * sin( (t*d-s)*(2*PI)/p )*.5f + c + b;
}