[−][src]Struct gravitas::Spring
a position controlled by a spring as defined by Hooke's law, F = -kx * cv
.
Depending on the values specified for the spring's mass, constant and damping, the spring may be underdamped, critically damped or overdamped. This textbook provides a good overview of the spring model used by Gravitas.
A critically damped spring satisfies: damping * damping - 4 * mass * spring_constant == 0
.
Methods
impl Spring
[src]
pub fn new(mass: f32, spring_constant: f32, damping: f32) -> Spring
[src]
Create a new spring with the given mass, spring constant and damping values.
The spring starts out "snapped" to 0.0.
pub fn set(&mut self, x: f32, velocity: f32, time: f32)
[src]
Set the spring's endpoint to the given position and velocity. If time is non-zero then the velocity of the spring at that time (before these new values are applied) is also included.
pub fn snap(&mut self, x: f32)
[src]
"Snap" the spring and set the value. The spring simulation will return this value with no velocity for all time (or until set is called again) once snapped.
Trait Implementations
impl Simulation for Spring
[src]
fn x(&self, time: f32) -> f32
[src]
fn dx(&self, time: f32) -> f32
[src]
fn is_done(&self, time: f32) -> bool
[src]
impl Clone for Spring
[src]
impl Copy for Spring
[src]
Auto Trait Implementations
impl Send for Spring
impl Sync for Spring
impl Unpin for Spring
impl UnwindSafe for Spring
impl RefUnwindSafe for Spring
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,