7 constexpr double PI = 3.1415926545;
9 double easeInSine(
double t) {
return sin(1.5707963 * t); }
11 double easeOutSine(
double t) {
return 1 + sin(1.5707963 * (--t)); }
13 double easeInOutSine(
double t) {
return 0.5 * (1 + sin(3.1415926 * (t - 0.5))); }
15 double easeInQuad(
double t) {
return t * t; }
17 double easeOutQuad(
double t) {
return t * (2 - t); }
19 double easeInOutQuad(
double t) {
return t < 0.5 ? 2 * t * t : t * (4 - 2 * t) - 1; }
21 double easeInCubic(
double t) {
return t * t * t; }
23 double easeOutCubic(
double t) {
return 1 + (--t) * t * t; }
25 double easeInOutCubic(
double t) {
return t < 0.5 ? 4 * t * t * t : 1 + (--t) * (2 * (--t)) * (2 * t); }
27 double easeInQuart(
double t)
33 double easeOutQuart(
double t)
39 double easeInOutQuart(
double t)
53 double easeInQuint(
double t)
59 double easeOutQuint(
double t)
61 double t2 = (--t) * t;
62 return 1 + t * t2 * t2;
65 double easeInOutQuint(
double t)
71 return 16 * t * t2 * t2;
76 return 1 + 16 * t * t2 * t2;
80 double easeInExpo(
double t) {
return (pow(2, 8 * t) - 1) / 255; }
82 double easeOutExpo(
double t) {
return 1 - pow(2, -8 * t); }
84 double easeInOutExpo(
double t)
88 return (pow(2, 16 * t) - 1) / 510;
92 return 1 - 0.5 * pow(2, -16 * (t - 0.5));
96 double easeInCirc(
double t) {
return 1 - sqrt(1 - t); }
98 double easeOutCirc(
double t) {
return sqrt(t); }
100 double easeInOutCirc(
double t)
104 return (1 - sqrt(1 - 2 * t)) * 0.5;
108 return (1 + sqrt(2 * t - 1)) * 0.5;
112 double easeInBack(
double t) {
return t * t * (2.70158 * t - 1.70158); }
114 double easeOutBack(
double t) {
return 1 + (--t) * t * (2.70158 * t + 1.70158); }
116 double easeInOutBack(
double t)
120 return t * t * (7 * t - 2.5) * 2;
124 return 1 + (--t) * t * 2 * (7 * t + 2.5);
128 double easeInElastic(
double t)
131 return t2 * t2 * sin(t * PI * 4.5);
134 double easeOutElastic(
double t)
136 double t2 = (t - 1) * (t - 1);
137 return 1 - t2 * t2 * cos(t * PI * 4.5);
140 double easeInOutElastic(
double t)
146 return 8 * t2 * t2 * sin(t * PI * 9);
150 return 0.5 + 0.75 * sin(t * PI * 4);
154 t2 = (t - 1) * (t - 1);
155 return 1 - 8 * t2 * t2 * sin(t * PI * 9);
159 double easeInBounce(
double t) {
return pow(2, 6 * (t - 1)) * abs(sin(t * PI * 3.5)); }
161 double easeOutBounce(
double t) {
return 1 - pow(2, -6 * t) * abs(cos(t * PI * 3.5)); }
163 double easeInOutBounce(
double t)
167 return 8 * pow(2, 8 * (t - 1)) * abs(sin(t * PI * 7));
171 return 1 - 8 * pow(2, -8 * t) * abs(sin(t * PI * 7));