Struct rapier2d::dynamics::MassProperties

source ·
pub struct MassProperties {
    pub local_com: OPoint<f32, Const<2>>,
    pub inv_mass: f32,
    pub inv_principal_inertia_sqrt: f32,
}
Expand description

The local mass properties of a rigid-body.

Fields§

§local_com: OPoint<f32, Const<2>>

The center of mass of a rigid-body expressed in its local-space.

§inv_mass: f32

The inverse of the mass of a rigid-body.

If this is zero, the rigid-body is assumed to have infinite mass.

§inv_principal_inertia_sqrt: f32

The inverse of the principal angular inertia of the rigid-body.

The angular inertia is calculated relative to Self::local_com. Components set to zero are assumed to be infinite along the corresponding principal axis.

Implementations§

source§

impl MassProperties

source

pub fn new( local_com: OPoint<f32, Const<2>>, mass: f32, principal_inertia: f32 ) -> MassProperties

Initializes the mass properties with the given center-of-mass, mass, and angular inertia.

The center-of-mass is specified in the local-space of the rigid-body.

source

pub fn mass(&self) -> f32

The mass.

source

pub fn principal_inertia(&self) -> f32

The angular inertia along the principal inertia axes and center of mass of the rigid-body.

source

pub fn world_com( &self, pos: &Isometry<f32, Unit<Complex<f32>>, 2> ) -> OPoint<f32, Const<2>>

The world-space center of mass of the rigid-body.

source

pub fn world_inv_inertia_sqrt(&self, _rot: &Unit<Complex<f32>>) -> f32

The world-space inverse angular inertia tensor of the rigid-body.

source

pub fn transform_by( &self, m: &Isometry<f32, Unit<Complex<f32>>, 2> ) -> MassProperties

Transform each element of the mass properties.

source

pub fn set_mass(&mut self, new_mass: f32, adjust_angular_inertia: bool)

Changes the mass on these mass-properties.

The adjust_angular_inertia argument should always be true, unless there are some specific reasons not to do so. Setting this to true will automatically adjust the angular inertia of self to account for the mass change (i.e. it will multiply the angular inertia by new_mass / prev_mass). Setting it to false will not change the current angular inertia.

source§

impl MassProperties

source

pub fn from_ball(density: f32, radius: f32) -> MassProperties

Computes the mass properties of a ball.

source§

impl MassProperties

source

pub fn from_capsule( density: f32, a: OPoint<f32, Const<2>>, b: OPoint<f32, Const<2>>, radius: f32 ) -> MassProperties

Computes the mass properties of a capsule.

source§

impl MassProperties

source

pub fn from_compound( density: f32, shapes: &[(Isometry<f32, Unit<Complex<f32>>, 2>, SharedShape)] ) -> MassProperties

Computes the mass properties of a compound shape.

source§

impl MassProperties

source

pub fn from_convex_polygon( density: f32, vertices: &[OPoint<f32, Const<2>>] ) -> MassProperties

Computes the mass properties of a convex polygon.

source§

impl MassProperties

source

pub fn from_cuboid( density: f32, half_extents: Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>> ) -> MassProperties

Computes the mass properties of a cuboid.

source§

impl MassProperties

source

pub fn from_triangle( density: f32, a: &OPoint<f32, Const<2>>, b: &OPoint<f32, Const<2>>, c: &OPoint<f32, Const<2>> ) -> MassProperties

Computes the mass properties of a triangle.

source§

impl MassProperties

source

pub fn from_trimesh( density: f32, vertices: &[OPoint<f32, Const<2>>], indices: &[[u32; 3]] ) -> MassProperties

Computes the mass properties of a triangle-mesh.

Trait Implementations§

source§

impl AbsDiffEq for MassProperties

§

type Epsilon = f32

Used for specifying relative comparisons.
source§

fn default_epsilon() -> <MassProperties as AbsDiffEq>::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn abs_diff_eq( &self, other: &MassProperties, epsilon: <MassProperties as AbsDiffEq>::Epsilon ) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
source§

impl Add for MassProperties

§

type Output = MassProperties

The resulting type after applying the + operator.
source§

fn add(self, other: MassProperties) -> MassProperties

Performs the + operation. Read more
source§

impl AddAssign for MassProperties

source§

fn add_assign(&mut self, rhs: MassProperties)

Performs the += operation. Read more
source§

impl Clone for MassProperties

source§

fn clone(&self) -> MassProperties

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MassProperties

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for MassProperties

source§

fn default() -> MassProperties

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for MassProperties

source§

fn deserialize<__D>( __deserializer: __D ) -> Result<MassProperties, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<MassProperties> for ColliderMassProps

source§

fn from(mprops: MassProperties) -> Self

Converts to this type from the input type.
source§

impl From<MassProperties> for RigidBodyMassProps

source§

fn from(local_mprops: MassProperties) -> Self

Converts to this type from the input type.
source§

impl PartialEq for MassProperties

source§

fn eq(&self, other: &MassProperties) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl RelativeEq for MassProperties

source§

fn default_max_relative() -> <MassProperties as AbsDiffEq>::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &MassProperties, epsilon: <MassProperties as AbsDiffEq>::Epsilon, max_relative: <MassProperties as AbsDiffEq>::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of RelativeEq::relative_eq.
source§

impl Serialize for MassProperties

source§

fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Sub for MassProperties

§

type Output = MassProperties

The resulting type after applying the - operator.
source§

fn sub(self, other: MassProperties) -> MassProperties

Performs the - operation. Read more
source§

impl SubAssign for MassProperties

source§

fn sub_assign(&mut self, rhs: MassProperties)

Performs the -= operation. Read more
source§

impl Sum for MassProperties

source§

fn sum<I>(iter: I) -> MassProperties
where I: Iterator<Item = MassProperties>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Zero for MassProperties

source§

fn zero() -> MassProperties

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl Copy for MassProperties

source§

impl StructuralPartialEq for MassProperties

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T, Right> ClosedAdd<Right> for T
where T: Add<Right, Output = T> + AddAssign<Right>,

source§

impl<T, Right> ClosedSub<Right> for T
where T: Sub<Right, Output = T> + SubAssign<Right>,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,