rustic_mountain_core/
utils.rs1use std::f32::consts::PI;
2
3pub fn min(v1: f32, v2: f32) -> f32 {
11 f32::min(v1, v2)
12}
13pub fn sin(percentage: f32) -> f32 {
14 f32::sin(percentage * -2.0 * PI)
16}
17pub fn cos(percentage: f32) -> f32 {
18 f32::cos(percentage * -2.0 * PI)
20}
21pub fn sign(v: f32) -> f32 {
22 if v != 0f32 {
23 v.signum()
24 } else {
25 0f32
26 }
27}
28pub fn max(v1: f32, v2: f32) -> f32 {
29 f32::max(v1, v2)
30}
31pub fn appr(val: f32, target: f32, amount: f32) -> f32 {
32 if val > target {
33 max(val - amount, target)
34 } else {
35 min(val + amount, target)
36 }
37}
38pub fn mid(v1: f32, v2: f32, v3: f32) -> f32 {
39 return v1.max(v2).min(v3);
40}