6#include <glm/gtc/constants.hpp>
9float Cogs::EasingFn::linear(
float t) {
13float Cogs::EasingFn::quadraticIn(
float t) {
17float Cogs::EasingFn::quadraticOut(
float t) {
18 return t * (2.0f - t);
21float Cogs::EasingFn::quadraticInOut(
float t) {
29 return -0.5f * (t * (t - 2.0f) - 1.0f);
32float Cogs::EasingFn::cubicIn(
float t) {
36float Cogs::EasingFn::cubicOut(
float t) {
38 return (t * t * t) + 1.0f;
41float Cogs::EasingFn::cubicInOut(
float t) {
45 return 0.5f * t * t * t;
49 return 0.5f * ((t * t * t) + 2.0f);
52float Cogs::EasingFn::quarticIn(
float t) {
56float Cogs::EasingFn::quarticOut(
float t) {
58 return 1 - (t * t * t * t);
61float Cogs::EasingFn::quarticInOut(
float t) {
65 return 0.5f * t * t * t * t;
69 return -0.5f * ((t * t * t * t) - 2.0f);
72float Cogs::EasingFn::quinticIn(
float t) {
73 return t * t * t * t * t;
76float Cogs::EasingFn::quinticOut(
float t) {
78 return (t * t * t * t * t) + 1.0f;
81float Cogs::EasingFn::quinticInOut(
float t) {
85 return 0.5f * t * t * t * t * t;
89 return 0.5f * ((t * t * t * t * t) + 2.0f);
92float Cogs::EasingFn::sinusoidalIn(
float t) {
93 return 1.0f - std::cos(t * glm::pi<float>() * 0.5f);
96float Cogs::EasingFn::sinusoidalOut(
float t) {
97 return std::sin(t * glm::pi<float>() * 0.5f);
100float Cogs::EasingFn::sinusoidalInOut(
float t) {
101 return 0.5f * (1.0f - std::cos(glm::pi<float>() * t));
104float Cogs::EasingFn::exponentialIn(
float t) {
105 return (t == 0.0f) ? 0.0f : std::pow(1024.0f, t - 1.0f);
108float Cogs::EasingFn::exponentialOut(
float t) {
109 return (t == 1.0f) ? 1.0f : (1.0f - std::pow(2.0f, -10.0f * t));
112float Cogs::EasingFn::exponentialInOut(
float t) {
116 else if (t == 1.0f) {
123 return 0.5f * std::pow(1024.0f, t - 1.0f);
125 return 0.5f * (-std::pow(2.0f, -10.0f * (t - 1.0f)) + 2.0f);
128float Cogs::EasingFn::circularIn(
float t) {
129 return 1.0f - std::sqrt(1.0f - (t * t));
132float Cogs::EasingFn::circularOut(
float t) {
134 return std::sqrt(1.0f - (t * t));
137float Cogs::EasingFn::circularInOut(
float t) {
141 return -0.5f * (std::sqrt(1.0f - (t * t)) - 1.0f);
144 return 0.5f * (std::sqrt(1.0f - (t * t)) + 1.0f);
147float Cogs::EasingFn::elasticIn(
float t) {
151 else if (t == 1.0f) {
156 return -std::pow(2.0f, 10.0f * t) * std::sin((t - 0.1f) * (2.0f * glm::pi<float>()) * 2.5f);
159float Cogs::EasingFn::elasticOut(
float t) {
163 else if (t == 1.0f) {
167 return (std::pow(2.0f, -10.0f * t) * std::sin((t - 0.1f) * (2.0f * glm::pi<float>()) * 2.5f)) + 1.0f;
170float Cogs::EasingFn::elasticInOut(
float t) {
174 else if (t == 1.0f) {
178 t = (t * 2.0f) - 1.0f;
181 return -0.5f * std::pow(2.0f, 10.0f * t) * std::sin((t - 0.1f) * (2.0f * glm::pi<float>()) * 2.5f);
184 return (std::pow(2.0f, -10.0f * t) * std::sin((t - 0.1f) * (2.0f * glm::pi<float>()) * 2.5f) * 0.5f) + 1.0f;
187float Cogs::EasingFn::backIn(
float t) {
188 return t * t * ((2.70158f * t) - 1.70158f);
191float Cogs::EasingFn::backOut(
float t) {
193 return (t * t * ((2.70158f * t) + 1.70158f)) + 1.0f;
196float Cogs::EasingFn::backInOut(
float t) {
197 float s = 1.70158f * 1.525f;
202 return 0.5f * (t * t * (((s + 1.0f) * t) - s));
206 return 0.5f * (t * t * (((s + 1.0f) * t) + s) + 2.0f);
209float Cogs::EasingFn::bounceIn(
float t) {
210 return 1.0f - bounceOut(1.0f - t);
213float Cogs::EasingFn::bounceOut(
float t) {
214 if (t < (1.0f / 2.75f)) {
215 return 7.5625f * t * t;
217 else if (t < (2.0f / 2.75f)) {
219 return (7.5625f * t * t) + 0.75f;
221 else if (t < (2.5f / 2.75f)) {
223 return (7.562f * t * t) + 0.9375f;
227 return (7.5625f * t * t) + 0.984375f;
231float Cogs::EasingFn::bounceInOut(
float t) {
233 return bounceIn(t * 2.0f) * 0.5f;
235 return (bounceOut((t * 2.0f) - 1.0f) * 0.5f) + 0.5f;