pub struct Spring { /* private fields */ }Expand description
The analytic response of a SpringDesc released from an initial displacement
and velocity toward equilibrium at 0.
Spring::position returns displacements from the target. The closed-form
solution is exact in all three damping regimes, so a fling can be evaluated
at any frame time without accumulating step error.
Implementations§
Source§impl Spring
impl Spring
Sourcepub fn new(desc: SpringDesc, x0: f64, v0: f64) -> Self
pub fn new(desc: SpringDesc, x0: f64, v0: f64) -> Self
Solve the spring released from displacement x0 with initial velocity v0.
Non-positive mass/stiffness fall back to a critically damped unit spring, so
the constructor never produces NaN.
Sourcepub fn position(&self, t: f64) -> f64
pub fn position(&self, t: f64) -> f64
The displacement from equilibrium at elapsed time t (seconds).
Sourcepub fn velocity(&self, t: f64) -> f64
pub fn velocity(&self, t: f64) -> f64
The velocity (d displacement / d t) at elapsed time t (seconds).
Sourcepub fn is_at_rest(&self, t: f64, epsilon: f64) -> bool
pub fn is_at_rest(&self, t: f64, epsilon: f64) -> bool
Whether both |position| and |velocity| are below epsilon at time t.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Spring
impl RefUnwindSafe for Spring
impl Send for Spring
impl Sync for Spring
impl Unpin for Spring
impl UnsafeUnpin for Spring
impl UnwindSafe for Spring
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.