eazy_data/
interpolation.rs1pub mod linear;
2pub mod piecewize;
3pub mod polynomial;
4pub mod rational;
5pub mod trigonometric;
6
7use crate::Curve;
8
9#[derive(Debug, Clone)]
24pub enum Interpolation {
25 None,
27 Linear,
30 InSmooth,
32 OutSmooth,
33 InOutSmooth,
34 InSmoother,
36 OutSmoother,
37 InOutSmoother,
38 Quartic,
40 InvQuartic,
41 InRationalCubic,
43 InRationalQuadratic,
44 OutRationalCubic,
46 OutRationalQuadratic,
47 InPiecewizePolynomial,
49 InPiecewizeQuadratic,
50 OutPiecewizePolynomial,
52 OutPiecewizeQuadratic,
53 Sinusoidal,
55 InvSinusoidal,
56}
57
58impl Curve for Interpolation {
59 #[inline(always)]
60 fn y(&self, p: f32) -> f32 {
61 match self {
62 Self::None => polynomial::none::None.y(p),
63 Self::Linear => p, Self::InSmooth => polynomial::smoothstep::InSmooth.y(p),
65 Self::OutSmooth => polynomial::smoothstep::OutSmooth.y(p),
66 Self::InOutSmooth => polynomial::smoothstep::InOutSmooth.y(p),
67 Self::InSmoother => polynomial::smootherstep::InSmoother.y(p),
68 Self::OutSmoother => polynomial::smootherstep::OutSmoother.y(p),
69 Self::InOutSmoother => polynomial::smootherstep::InOutSmoother.y(p),
70 Self::Quartic => polynomial::quartic::Quartic.y(p),
71 Self::InvQuartic => polynomial::quartic::InvQuartic.y(p),
72 Self::InRationalCubic => rational::cubic::InRationalCubic.y(p),
73 Self::InRationalQuadratic => {
74 rational::quadratic::InRationalQuadratic.y(p)
75 }
76 Self::OutRationalCubic => rational::cubic::OutRationalCubic.y(p),
77 Self::OutRationalQuadratic => {
78 rational::quadratic::OutRationalQuadratic.y(p)
79 }
80 Self::InPiecewizePolynomial => {
81 piecewize::polynomial::InPiecewizePolynomial.y(p)
82 }
83 Self::InPiecewizeQuadratic => {
84 piecewize::quadratic::InPiecewizeQuadratic.y(p)
85 }
86 Self::OutPiecewizePolynomial => {
87 piecewize::polynomial::OutPiecewizePolynomial.y(p)
88 }
89 Self::OutPiecewizeQuadratic => {
90 piecewize::quadratic::OutPiecewizeQuadratic.y(p)
91 }
92 Self::Sinusoidal => trigonometric::sinusoidal::Sinusoidal.y(p),
93 Self::InvSinusoidal => trigonometric::sinusoidal::InvSinusoidal.y(p),
94 }
95 }
96}