1const C1: f32 = 1.70158;
2const C2: f32 = C1 * 1.525;
3const C3: f32 = C1 + 1.0;
4
5#[inline]
7#[must_use]
8pub fn back_in(t: f32) -> f32 {
9 (C3 * t * t).mul_add(t, -(C1 * t * t))
10}
11
12#[inline]
14#[must_use]
15pub fn back_out(t: f32) -> f32 {
16 C1.mul_add((t - 1.0).powi(2), C3.mul_add((t - 1.0).powi(3), 1.0))
17}
18
19#[inline]
21#[must_use]
22pub fn back_in_out(t: f32) -> f32 {
23 if t < 0.5 {
24 ((2.0 * t).powi(2) * ((C2 + 1.0) * 2.0).mul_add(t, -C2)) / 2.0
25 } else {
26 f32::midpoint(
27 2.0f32.mul_add(t, -2.0).powi(2) * (C2 + 1.0).mul_add(t.mul_add(2.0, -2.0), C2),
28 2.0,
29 )
30 }
31}