Enum rapier2d::dynamics::SpringModel[][src]

pub enum SpringModel {
    Disabled,
    VelocityBased,
    AccelerationBased,
    ForceBased,
}

The spring-like model used for constraints resolution.

Variants

Disabled

No equation is solved.

VelocityBased

The solved spring-like equation is: delta_velocity(t + dt) = stiffness / dt * (target_pos - pos(t)) + damping * (target_vel - vel(t))

Here the stiffness is the ratio of position error to be solved at each timestep (like a velocity-based ERP), and the damping is the ratio of velocity error to be solved at each timestep.

AccelerationBased

The solved spring-like equation is: acceleration(t + dt) = stiffness * (target_pos - pos(t)) + damping * (target_vel - vel(t))

ForceBased

The solved spring-like equation is: force(t + dt) = stiffness * (target_pos - pos(t + dt)) + damping * (target_vel - vel(t + dt))

Implementations

impl SpringModel[src]

pub fn combine_coefficients(
    self,
    dt: Real,
    stiffness: Real,
    damping: Real
) -> (Real, Real, Real, bool)
[src]

Combines the coefficients used for solving the spring equation.

Returns the new coefficients (stiffness, damping, inv_lhs_scale, keep_inv_lhs) coefficients for the equivalent impulse-based equation. These new coefficients must be used in the following way:

  • rhs = (stiffness * pos_err + damping * vel_err) / gamma.
  • new_inv_lhs = gamma * if keep_inv_lhs { inv_lhs } else { 1.0 }. Note that the returned gamma will be zero if both stiffness and damping are zero.

Trait Implementations

impl Clone for SpringModel[src]

impl Copy for SpringModel[src]

impl Debug for SpringModel[src]

impl Default for SpringModel[src]

impl Eq for SpringModel[src]

impl PartialEq<SpringModel> for SpringModel[src]

impl StructuralEq for SpringModel[src]

impl StructuralPartialEq for SpringModel[src]

Auto Trait Implementations

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> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Any + Send + Sync
[src]

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

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

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Debug + Any
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 
[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.