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
impl MassProperties
Sourcepub fn new(
local_com: OPoint<f32, Const<2>>,
mass: f32,
principal_inertia: f32,
) -> MassProperties
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.
Sourcepub fn principal_inertia(&self) -> f32
pub fn principal_inertia(&self) -> f32
The angular inertia along the principal inertia axes and center of mass of the rigid-body.
Sourcepub fn world_com(
&self,
pos: &Isometry<f32, Unit<Complex<f32>>, 2>,
) -> OPoint<f32, Const<2>>
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.
Sourcepub fn world_inv_inertia_sqrt(&self, _rot: &Unit<Complex<f32>>) -> f32
pub fn world_inv_inertia_sqrt(&self, _rot: &Unit<Complex<f32>>) -> f32
The world-space inverse angular inertia tensor of the rigid-body.
Sourcepub fn transform_by(
&self,
m: &Isometry<f32, Unit<Complex<f32>>, 2>,
) -> MassProperties
pub fn transform_by( &self, m: &Isometry<f32, Unit<Complex<f32>>, 2>, ) -> MassProperties
Transform each element of the mass properties.
Sourcepub fn set_mass(&mut self, new_mass: f32, adjust_angular_inertia: bool)
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
impl MassProperties
Sourcepub fn from_ball(density: f32, radius: f32) -> MassProperties
pub fn from_ball(density: f32, radius: f32) -> MassProperties
Computes the mass properties of a ball.
Source§impl MassProperties
impl MassProperties
Sourcepub fn from_compound(
density: f32,
shapes: &[(Isometry<f32, Unit<Complex<f32>>, 2>, SharedShape)],
) -> MassProperties
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
impl MassProperties
Sourcepub fn from_convex_polygon(
density: f32,
vertices: &[OPoint<f32, Const<2>>],
) -> MassProperties
pub fn from_convex_polygon( density: f32, vertices: &[OPoint<f32, Const<2>>], ) -> MassProperties
Computes the mass properties of a convex polygon.
Source§impl MassProperties
impl MassProperties
Sourcepub fn from_cuboid(
density: f32,
half_extents: Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>,
) -> MassProperties
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
impl MassProperties
Sourcepub fn from_trimesh(
density: f32,
vertices: &[OPoint<f32, Const<2>>],
indices: &[[u32; 3]],
) -> MassProperties
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
impl AbsDiffEq for MassProperties
Source§fn default_epsilon() -> <MassProperties as AbsDiffEq>::Epsilon
fn default_epsilon() -> <MassProperties as AbsDiffEq>::Epsilon
Source§fn abs_diff_eq(
&self,
other: &MassProperties,
epsilon: <MassProperties as AbsDiffEq>::Epsilon,
) -> bool
fn abs_diff_eq( &self, other: &MassProperties, epsilon: <MassProperties as AbsDiffEq>::Epsilon, ) -> bool
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq
.Source§impl Add for MassProperties
impl Add for MassProperties
Source§type Output = MassProperties
type Output = MassProperties
+
operator.Source§fn add(self, other: MassProperties) -> MassProperties
fn add(self, other: MassProperties) -> MassProperties
+
operation. Read moreSource§impl AddAssign for MassProperties
impl AddAssign for MassProperties
Source§fn add_assign(&mut self, rhs: MassProperties)
fn add_assign(&mut self, rhs: MassProperties)
+=
operation. Read moreSource§impl Clone for MassProperties
impl Clone for MassProperties
Source§fn clone(&self) -> MassProperties
fn clone(&self) -> MassProperties
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for MassProperties
impl Debug for MassProperties
Source§impl Default for MassProperties
impl Default for MassProperties
Source§fn default() -> MassProperties
fn default() -> MassProperties
Source§impl From<MassProperties> for ColliderMassProps
impl From<MassProperties> for ColliderMassProps
Source§fn from(mprops: MassProperties) -> Self
fn from(mprops: MassProperties) -> Self
Source§impl From<MassProperties> for RigidBodyMassProps
impl From<MassProperties> for RigidBodyMassProps
Source§fn from(local_mprops: MassProperties) -> Self
fn from(local_mprops: MassProperties) -> Self
Source§impl PartialEq for MassProperties
impl PartialEq for MassProperties
Source§impl RelativeEq for MassProperties
impl RelativeEq for MassProperties
Source§fn default_max_relative() -> <MassProperties as AbsDiffEq>::Epsilon
fn default_max_relative() -> <MassProperties as AbsDiffEq>::Epsilon
Source§fn relative_eq(
&self,
other: &MassProperties,
epsilon: <MassProperties as AbsDiffEq>::Epsilon,
max_relative: <MassProperties as AbsDiffEq>::Epsilon,
) -> bool
fn relative_eq( &self, other: &MassProperties, epsilon: <MassProperties as AbsDiffEq>::Epsilon, max_relative: <MassProperties as AbsDiffEq>::Epsilon, ) -> bool
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq
.Source§impl Sub for MassProperties
impl Sub for MassProperties
Source§type Output = MassProperties
type Output = MassProperties
-
operator.Source§fn sub(self, other: MassProperties) -> MassProperties
fn sub(self, other: MassProperties) -> MassProperties
-
operation. Read moreSource§impl SubAssign for MassProperties
impl SubAssign for MassProperties
Source§fn sub_assign(&mut self, rhs: MassProperties)
fn sub_assign(&mut self, rhs: MassProperties)
-=
operation. Read moreSource§impl Sum for MassProperties
impl Sum for MassProperties
Source§fn sum<I>(iter: I) -> MassPropertieswhere
I: Iterator<Item = MassProperties>,
fn sum<I>(iter: I) -> MassPropertieswhere
I: Iterator<Item = MassProperties>,
Self
from the elements by “summing up”
the items.Source§impl Zero for MassProperties
impl Zero for MassProperties
impl Copy for MassProperties
impl StructuralPartialEq for MassProperties
Auto Trait Implementations§
impl Freeze for MassProperties
impl RefUnwindSafe for MassProperties
impl Send for MassProperties
impl Sync for MassProperties
impl Unpin for MassProperties
impl UnwindSafe for MassProperties
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.