[][src]Struct gravitas::Gravity

pub struct Gravity { /* fields omitted */ }

a position under the influence of gravity (or any other constant acceleration), as defined by Newton's 2nd Law: F = ma.

Newton's 2nd law, F = ma, integrates to x' = x + v * t + 0.5 * a * t * t, which is what this simulation uses to compute a position.

This simulation is nice for objects that are falling, or have to overcome gravity in some way.

Methods

impl Gravity[src]

pub fn new(a: f32) -> Gravity[src]

Create a new gravity siulation with the given acceleration. A value of 500 * 9.8 (so 500px corresponds to 1 meter) is normally a good starting point.

pub fn set(&mut self, x: f32, v: f32)[src]

Set the initial position and velocity (in pixels per second) of the gravity simulation.

Trait Implementations

impl Clone for Gravity[src]

impl Copy for Gravity[src]

impl Simulation for Gravity[src]

Auto Trait Implementations

impl RefUnwindSafe for Gravity

impl Send for Gravity

impl Sync for Gravity

impl Unpin for Gravity

impl UnwindSafe for Gravity

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.