From f9a303108504eac8e5d5879ea1012e116e5a225f Mon Sep 17 00:00:00 2001 From: Danny McGee Date: Fri, 13 Oct 2023 18:04:39 -0400 Subject: [PATCH] Move `curve_sin` to `interpolation` module --- studio/src/math/interpolation.rs | 10 +++++++++- studio/src/math/util.rs | 10 ---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/studio/src/math/interpolation.rs b/studio/src/math/interpolation.rs index bd29f52..d434330 100644 --- a/studio/src/math/interpolation.rs +++ b/studio/src/math/interpolation.rs @@ -1,4 +1,4 @@ -use std::ops; +use std::{f32::consts, ops}; use super::NearlyEq; @@ -52,3 +52,11 @@ where t.lerp(to.0, to.1) } } + +/// Fit a [0, 1] `t` interpolation parameter to a sine curve +/// +/// https://www.desmos.com/calculator/k9x4c4cr5y +#[inline] +pub fn curve_sin(t: f32) -> f32 { + -1. * (f32::cos(t * consts::PI) / 2.) + 0.5 +} diff --git a/studio/src/math/util.rs b/studio/src/math/util.rs index a539ccc..c7dafe2 100644 --- a/studio/src/math/util.rs +++ b/studio/src/math/util.rs @@ -1,5 +1,3 @@ -use std::f32::consts; - use bevy::prelude::Vec3; pub trait NearlyEq { @@ -17,11 +15,3 @@ impl NearlyEq for Vec3 { self.x.nearly_eq(rhs.x) && self.y.nearly_eq(rhs.y) && self.z.nearly_eq(rhs.z) } } - -/// Fit a [0, 1] `t` interpolation parameter to a sine curve -/// -/// https://www.desmos.com/calculator/k9x4c4cr5y -#[inline] -pub fn curve_sin(t: f32) -> f32 { - -1. * (f32::cos(t * consts::PI) / 2.) + 0.5 -}