mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-17 00:13:17 +00:00
Move curve_sin to interpolation module
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::f32::consts;
|
||||
|
||||
use bevy::prelude::Vec3;
|
||||
|
||||
pub trait NearlyEq<Rhs> {
|
||||
@@ -17,11 +15,3 @@ impl NearlyEq<Vec3> 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user