Skip to content

Instantly share code, notes, and snippets.

@OllieReynolds
Created November 19, 2016 00:43
Show Gist options
  • Save OllieReynolds/0cb14a90871ec579cddb1f388bdad1b2 to your computer and use it in GitHub Desktop.
Save OllieReynolds/0cb14a90871ec579cddb1f388bdad1b2 to your computer and use it in GitHub Desktop.
#include <iostream>
// Credit to: https://github.com/warrenm/AHEasing/blob/master/AHEasing/easing.c
double CubicEaseInOut(double p) {
if (p < 0.5) {
return 4 * p * p * p;
} else {
double f = ((2 * p) - 2);
return 0.5 * f * f * f + 1;
}
}
int main() {
double step = 0.05;
for (double i = 0; i < 1.0; i += step) {
std::cout << CubicEaseInOut(i) << std::endl;
}
system("pause");
}
/*
OUTPUT:
0
0.0005
0.004
0.0135
0.032
0.0625
0.108
0.1715
0.256
0.3645
0.5
0.6355
0.744
0.8285
0.892
0.9375
0.968
0.9865
0.996
0.9995
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment