1#[must_use]
3#[inline(always)]
4pub fn bounce_in(t: f32) -> f32 {
5 1.0 - bounce_out(1.0 - t)
6}
7
8#[must_use]
10#[inline(always)]
11pub fn bounce_out(t: f32) -> f32 {
12 const N1: f32 = 7.5625;
13 const D1: f32 = 2.75;
14 if t < 1.0 / D1 {
15 N1 * t * t
16 } else if t < 2.0 / D1 {
17 return N1.mul_add((t - 1.5 / D1).powi(2), 0.75);
18 } else if t < 2.5 / D1 {
19 return N1.mul_add((t - 2.25 / D1).powi(2), 0.9375);
20 } else {
21 return N1.mul_add((t - 2.625 / D1).powi(2), 0.984_375);
22 }
23}
24
25#[must_use]
27#[inline(always)]
28pub fn bounce_in_out(t: f32) -> f32 {
29 if t < 0.5 {
30 (1.0 - bounce_out(2.0f32.mul_add(-t, 1.0))) / 2.0
31 } else {
32 (1.0 + bounce_out(2.0f32.mul_add(t, -1.0))) / 2.0
33 }
34}