[][src]Struct gravitas::Spring

pub struct Spring { /* fields omitted */ }

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 Clone for Spring[src]

impl Copy for Spring[src]

impl Simulation for Spring[src]

Auto Trait Implementations

impl RefUnwindSafe for Spring

impl Send for Spring

impl Sync for Spring

impl Unpin for Spring

impl UnwindSafe for Spring

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.