51 #ifndef ANTKEEPER_EASE_HPP
52 #define ANTKEEPER_EASE_HPP
69 template <
typename T,
typename S =
float>
75 static T
in_sine(
const T& x,
const T& y, S a);
76 static T
out_sine(
const T& x,
const T& y, S a);
79 static T
in_quad(
const T& x,
const T& y, S a);
80 static T
out_quad(
const T& x,
const T& y, S a);
83 static T
in_cubic(
const T& x,
const T& y, S a);
84 static T
out_cubic(
const T& x,
const T& y, S a);
87 static T
in_quart(
const T& x,
const T& y, S a);
88 static T
out_quart(
const T& x,
const T& y, S a);
91 static T
in_quint(
const T& x,
const T& y, S a);
92 static T
out_quint(
const T& x,
const T& y, S a);
95 static T
in_expo(
const T& x,
const T& y, S a);
96 static T
out_expo(
const T& x,
const T& y, S a);
99 static T
in_circ(
const T& x,
const T& y, S a);
100 static T
out_circ(
const T& x,
const T& y, S a);
103 static T
in_back(
const T& x,
const T& y, S a);
104 static T
out_back(
const T& x,
const T& y, S a);
107 static T
in_elastic(
const T& x,
const T& y, S a);
111 static T
in_bounce(
const T& x,
const T& y, S a);
112 static T
out_bounce(
const T& x,
const T& y, S a);
116 template <
typename T,
typename S>
119 return math::lerp(y, x, std::cos(a * math::half_pi<S>));
122 template <
typename T,
typename S>
125 return math::lerp(x, y, std::sin(a * math::half_pi<S>));
128 template <
typename T,
typename S>
131 return math::lerp(x, y, -(std::cos(a * math::pi<S>) - S(1)) * S(0.5));
134 template <
typename T,
typename S>
140 template <
typename T,
typename S>
146 template <
typename T,
typename S>
149 return math::lerp(x, y, (a < S(0.5)) ? S(2) * a * a : -(S(2) * a * a - S(4) * a + S(1)));
152 template <
typename T,
typename S>
158 template <
typename T,
typename S>
161 return math::lerp(x, y, a * ((a - S(3)) * a + S(3)));
164 template <
typename T,
typename S>
167 return math::lerp(x, y, (a < S(0.5)) ? S(4) * a * a * a : S(4) * a * a * a - S(12) * a * a + S(12) * a - 3);
170 template <
typename T,
typename S>
176 template <
typename T,
typename S>
179 return math::lerp(x, y, a * (a * ((S(4) - a) * a - S(6)) + S(4)));
182 template <
typename T,
typename S>
185 return math::lerp(x, y, (a < S(0.5)) ? S(8) * a * a * a * a : a * (a * ((S(32) - S(8) * a) * a - S(48)) + S(32)) - S(7));
188 template <
typename T,
typename S>
194 template <
typename T,
typename S>
197 return math::lerp(x, y, a * (a * (a * ((a - S(5)) * a + S(10)) - S(10)) + S(5)));
200 template <
typename T,
typename S>
205 return math::lerp(x, y, S(16) * a * a * a * a * a);
209 a = S(2) * (S(1) - a);
210 return math::lerp(x, y, S(0.5) * (S(2) - a * a * a * a * a));
214 template <
typename T,
typename S>
220 template <
typename T,
typename S>
226 template <
typename T,
typename S>
241 template <
typename T,
typename S>
247 template <
typename T,
typename S>
253 template <
typename T,
typename S>
266 template <
typename T,
typename S>
269 const S c = S(1.70158);
270 return math::lerp(x, y, a * a * (a * c + a - c));
273 template <
typename T,
typename S>
276 const S c = S(1.70158);
278 return math::lerp(x, y, a * a * (a * c + a + c) + S(1));
281 template <
typename T,
typename S>
284 const S c = S(1.70158) * S(1.525f);
288 return math::lerp(x, y, a * a * (a * (S(4) * c + S(4)) - S(2) * c));
292 S b = S(1) - S(2) * a;
293 return math::lerp(x, y, b * b * (a * c + a - c * S(0.5) - S(1)) + S(1));
297 template <
typename T,
typename S>
309 return math::lerp(x, y, -
std::pow(S(1024), a - S(1)) * std::sin(S(20.944) * (a - S(1.075))));
312 template <
typename T,
typename S>
324 return math::lerp(x, y,
std::pow(S(2), S(-10) * a) * std::sin(S(20.944) * (a - S(0.075))) + S(1));
327 template <
typename T,
typename S>
341 return math::lerp(x, y,
std::pow(S(2), S(20) * a - S(11)) * std::sin(S(15.5334) - S(27.5293) * a));
345 return math::lerp(y, x,
std::pow(2, S(9) - S(20) * a) * std::sin(S(15.5334) - S(27.5293) * a));
349 template <
typename T,
typename S>
355 template <
typename T,
typename S>
358 const S n = S(7.5625);
365 else if (a < S(2) / d)
368 a = n * a * a + S(0.75);
370 else if (a < S(2.5) / d)
373 a = n * a * a + S(0.9375);
378 a = n * a * a + S(0.984375);
384 template <
typename T,
typename S>
consteval T pow(T x, T e) noexcept
Compile-time pow for unsigned integrals.
vector< T, N > sqrt(const vector< T, N > &x)
Takes the square root of each element.
constexpr T lerp(const T &x, const T &y, S a) noexcept
Linearly interpolates between x and y.
Container for templated easing functions.
static T in_elastic(const T &x, const T &y, S a)
static T in_out_quad(const T &x, const T &y, S a)
static T in_out_elastic(const T &x, const T &y, S a)
static T in_out_sine(const T &x, const T &y, S a)
static T out_sine(const T &x, const T &y, S a)
static T in_out_bounce(const T &x, const T &y, S a)
static T out_cubic(const T &x, const T &y, S a)
static T out_back(const T &x, const T &y, S a)
static T out_bounce(const T &x, const T &y, S a)
static T in_sine(const T &x, const T &y, S a)
static T out_circ(const T &x, const T &y, S a)
static T in_quad(const T &x, const T &y, S a)
static T out_quint(const T &x, const T &y, S a)
static T in_bounce(const T &x, const T &y, S a)
static T in_out_circ(const T &x, const T &y, S a)
static T in_out_back(const T &x, const T &y, S a)
static T in_out_expo(const T &x, const T &y, S a)
static T in_back(const T &x, const T &y, S a)
static T in_out_quart(const T &x, const T &y, S a)
static T in_quint(const T &x, const T &y, S a)
static T in_out_cubic(const T &x, const T &y, S a)
static T in_out_quint(const T &x, const T &y, S a)
static T in_circ(const T &x, const T &y, S a)
static T out_expo(const T &x, const T &y, S a)
static T in_quart(const T &x, const T &y, S a)
static T out_quad(const T &x, const T &y, S a)
static T out_elastic(const T &x, const T &y, S a)
static T in_cubic(const T &x, const T &y, S a)
static T in_expo(const T &x, const T &y, S a)
static T out_quart(const T &x, const T &y, S a)