Struct rapier3d::dynamics::MassProperties
source · [−]pub struct MassProperties {
pub local_com: OPoint<f32, Const<3_usize>>,
pub inv_mass: f32,
pub inv_principal_inertia_sqrt: Matrix<f32, Const<3_usize>, Const<1_usize>, ArrayStorage<f32, 3_usize, 1_usize>>,
pub principal_inertia_local_frame: Unit<Quaternion<f32>>,
}
Expand description
The local mass properties of a rigid-body.
Fields
local_com: OPoint<f32, Const<3_usize>>
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: Matrix<f32, Const<3_usize>, Const<1_usize>, ArrayStorage<f32, 3_usize, 1_usize>>
The inverse of the principal angular inertia of the rigid-body.
Components set to zero are assumed to be infinite along the corresponding principal axis.
principal_inertia_local_frame: Unit<Quaternion<f32>>
The principal vectors of the local angular inertia tensor of the rigid-body.
Implementations
sourceimpl MassProperties
impl MassProperties
sourcepub fn new(
local_com: OPoint<f32, Const<3_usize>>,
mass: f32,
principal_inertia: Matrix<f32, Const<3_usize>, Const<1_usize>, ArrayStorage<f32, 3_usize, 1_usize>>
) -> MassProperties
pub fn new(
local_com: OPoint<f32, Const<3_usize>>,
mass: f32,
principal_inertia: Matrix<f32, Const<3_usize>, Const<1_usize>, ArrayStorage<f32, 3_usize, 1_usize>>
) -> MassProperties
Initializes the mass properties from the given center-of-mass, mass, and principal angular inertia.
The center-of-mass is specified in the local-space of the rigid-body. The principal angular inertia are the angular inertia along the coordinate axes in the local-space of the rigid-body.
sourcepub fn with_principal_inertia_frame(
local_com: OPoint<f32, Const<3_usize>>,
mass: f32,
principal_inertia: Matrix<f32, Const<3_usize>, Const<1_usize>, ArrayStorage<f32, 3_usize, 1_usize>>,
principal_inertia_local_frame: Unit<Quaternion<f32>>
) -> MassProperties
pub fn with_principal_inertia_frame(
local_com: OPoint<f32, Const<3_usize>>,
mass: f32,
principal_inertia: Matrix<f32, Const<3_usize>, Const<1_usize>, ArrayStorage<f32, 3_usize, 1_usize>>,
principal_inertia_local_frame: Unit<Quaternion<f32>>
) -> MassProperties
Initializes the mass properties from the given center-of-mass, mass, and principal angular inertia.
The center-of-mass is specified in the local-space of the rigid-body.
The principal angular inertia are the angular inertia along the coordinate axes defined by
the principal_inertia_local_frame
expressed in the local-space of the rigid-body.
sourcepub fn with_inertia_matrix(
local_com: OPoint<f32, Const<3_usize>>,
mass: f32,
inertia: Matrix<f32, Const<3_usize>, Const<3_usize>, ArrayStorage<f32, 3_usize, 3_usize>>
) -> MassProperties
pub fn with_inertia_matrix(
local_com: OPoint<f32, Const<3_usize>>,
mass: f32,
inertia: Matrix<f32, Const<3_usize>, Const<3_usize>, ArrayStorage<f32, 3_usize, 3_usize>>
) -> MassProperties
Initialize a new MassProperties
from a given center-of-mass, mass, and angular inertia matrix.
The angular inertia matrix will be diagonalized in order to extract the principal inertia values and principal inertia frame.
sourcepub fn principal_inertia(
&self
) -> Matrix<f32, Const<3_usize>, Const<1_usize>, ArrayStorage<f32, 3_usize, 1_usize>>
pub fn principal_inertia(
&self
) -> Matrix<f32, Const<3_usize>, Const<1_usize>, ArrayStorage<f32, 3_usize, 1_usize>>
The angular inertia along the principal inertia axes of the rigid-body.
sourcepub fn world_com(
&self,
pos: &Isometry<f32, Unit<Quaternion<f32>>, 3_usize>
) -> OPoint<f32, Const<3_usize>>
pub fn world_com(
&self,
pos: &Isometry<f32, Unit<Quaternion<f32>>, 3_usize>
) -> OPoint<f32, Const<3_usize>>
The world-space center of mass of the rigid-body.
sourcepub fn world_inv_inertia_sqrt(
&self,
rot: &Unit<Quaternion<f32>>
) -> SdpMatrix3<f32>
pub fn world_inv_inertia_sqrt(
&self,
rot: &Unit<Quaternion<f32>>
) -> SdpMatrix3<f32>
The world-space inverse angular inertia tensor of the rigid-body.
sourcepub fn reconstruct_inverse_inertia_matrix(
&self
) -> Matrix<f32, Const<3_usize>, Const<3_usize>, ArrayStorage<f32, 3_usize, 3_usize>>
pub fn reconstruct_inverse_inertia_matrix(
&self
) -> Matrix<f32, Const<3_usize>, Const<3_usize>, ArrayStorage<f32, 3_usize, 3_usize>>
Reconstructs the inverse angular inertia tensor of the rigid body from its principal inertia values and axes.
sourcepub fn reconstruct_inertia_matrix(
&self
) -> Matrix<f32, Const<3_usize>, Const<3_usize>, ArrayStorage<f32, 3_usize, 3_usize>>
pub fn reconstruct_inertia_matrix(
&self
) -> Matrix<f32, Const<3_usize>, Const<3_usize>, ArrayStorage<f32, 3_usize, 3_usize>>
Reconstructs the angular inertia tensor of the rigid body from its principal inertia values and axes.
sourcepub fn transform_by(
&self,
m: &Isometry<f32, Unit<Quaternion<f32>>, 3_usize>
) -> MassProperties
pub fn transform_by(
&self,
m: &Isometry<f32, Unit<Quaternion<f32>>, 3_usize>
) -> 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.
sourceimpl 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.
sourceimpl MassProperties
impl MassProperties
sourceimpl MassProperties
impl MassProperties
sourcepub fn from_compound(
density: f32,
shapes: &[(Isometry<f32, Unit<Quaternion<f32>>, 3_usize>, SharedShape)]
) -> MassProperties
pub fn from_compound(
density: f32,
shapes: &[(Isometry<f32, Unit<Quaternion<f32>>, 3_usize>, SharedShape)]
) -> MassProperties
Computes the mass properties of a compound shape.
sourceimpl MassProperties
impl MassProperties
sourceimpl MassProperties
impl MassProperties
sourceimpl MassProperties
impl MassProperties
sourcepub fn from_cuboid(
density: f32,
half_extents: Matrix<f32, Const<3_usize>, Const<1_usize>, ArrayStorage<f32, 3_usize, 1_usize>>
) -> MassProperties
pub fn from_cuboid(
density: f32,
half_extents: Matrix<f32, Const<3_usize>, Const<1_usize>, ArrayStorage<f32, 3_usize, 1_usize>>
) -> MassProperties
Computes the mass properties of a cuboid.
sourceimpl MassProperties
impl MassProperties
sourcepub fn from_cylinder(
density: f32,
half_height: f32,
radius: f32
) -> MassProperties
pub fn from_cylinder(
density: f32,
half_height: f32,
radius: f32
) -> MassProperties
Computes the mass properties of a cylinder.
Trait Implementations
sourceimpl AbsDiffEq<MassProperties> for MassProperties
impl AbsDiffEq<MassProperties> for MassProperties
sourcefn default_epsilon() -> <MassProperties as AbsDiffEq<MassProperties>>::Epsilon
fn default_epsilon() -> <MassProperties as AbsDiffEq<MassProperties>>::Epsilon
The default tolerance to use when testing values that are close together. Read more
sourcefn abs_diff_eq(
&self,
other: &MassProperties,
epsilon: <MassProperties as AbsDiffEq<MassProperties>>::Epsilon
) -> bool
fn abs_diff_eq(
&self,
other: &MassProperties,
epsilon: <MassProperties as AbsDiffEq<MassProperties>>::Epsilon
) -> bool
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
sourcefn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of AbsDiffEq::abs_diff_eq
.
sourceimpl Add<MassProperties> for MassProperties
impl Add<MassProperties> for MassProperties
type Output = MassProperties
type Output = MassProperties
The resulting type after applying the +
operator.
sourcefn add(self, other: MassProperties) -> MassProperties
fn add(self, other: MassProperties) -> MassProperties
Performs the +
operation. Read more
sourceimpl AddAssign<MassProperties> for MassProperties
impl AddAssign<MassProperties> for MassProperties
sourcefn add_assign(&mut self, rhs: MassProperties)
fn add_assign(&mut self, rhs: MassProperties)
Performs the +=
operation. Read more
sourceimpl Clone for MassProperties
impl Clone for MassProperties
sourcefn clone(&self) -> MassProperties
fn clone(&self) -> MassProperties
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for MassProperties
impl Debug for MassProperties
sourceimpl Default for MassProperties
impl Default for MassProperties
sourcefn default() -> MassProperties
fn default() -> MassProperties
Returns the “default value” for a type. Read more
sourceimpl From<MassProperties> for RigidBodyMassProps
impl From<MassProperties> for RigidBodyMassProps
sourcefn from(local_mprops: MassProperties) -> Self
fn from(local_mprops: MassProperties) -> Self
Converts to this type from the input type.
sourceimpl From<MassProperties> for ColliderMassProps
impl From<MassProperties> for ColliderMassProps
sourcefn from(mprops: MassProperties) -> Self
fn from(mprops: MassProperties) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<MassProperties> for MassProperties
impl PartialEq<MassProperties> for MassProperties
sourcefn eq(&self, other: &MassProperties) -> bool
fn eq(&self, other: &MassProperties) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &MassProperties) -> bool
fn ne(&self, other: &MassProperties) -> bool
This method tests for !=
.
sourceimpl RelativeEq<MassProperties> for MassProperties
impl RelativeEq<MassProperties> for MassProperties
sourcefn default_max_relative(
) -> <MassProperties as AbsDiffEq<MassProperties>>::Epsilon
fn default_max_relative(
) -> <MassProperties as AbsDiffEq<MassProperties>>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
sourcefn relative_eq(
&self,
other: &MassProperties,
epsilon: <MassProperties as AbsDiffEq<MassProperties>>::Epsilon,
max_relative: <MassProperties as AbsDiffEq<MassProperties>>::Epsilon
) -> bool
fn relative_eq(
&self,
other: &MassProperties,
epsilon: <MassProperties as AbsDiffEq<MassProperties>>::Epsilon,
max_relative: <MassProperties as AbsDiffEq<MassProperties>>::Epsilon
) -> bool
A test for equality that uses a relative comparison if the values are far apart.
sourcefn 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
The inverse of RelativeEq::relative_eq
.
sourceimpl Sub<MassProperties> for MassProperties
impl Sub<MassProperties> for MassProperties
type Output = MassProperties
type Output = MassProperties
The resulting type after applying the -
operator.
sourcefn sub(self, other: MassProperties) -> MassProperties
fn sub(self, other: MassProperties) -> MassProperties
Performs the -
operation. Read more
sourceimpl SubAssign<MassProperties> for MassProperties
impl SubAssign<MassProperties> for MassProperties
sourcefn sub_assign(&mut self, rhs: MassProperties)
fn sub_assign(&mut self, rhs: MassProperties)
Performs the -=
operation. Read more
sourceimpl Sum<MassProperties> for MassProperties
impl Sum<MassProperties> for MassProperties
sourcefn sum<I>(iter: I) -> MassProperties where
I: Iterator<Item = MassProperties>,
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. Read more
sourceimpl Zero for MassProperties
impl Zero for MassProperties
impl Copy for MassProperties
impl StructuralPartialEq for MassProperties
Auto Trait Implementations
impl RefUnwindSafe for MassProperties
impl Send for MassProperties
impl Sync for MassProperties
impl Unpin for MassProperties
impl UnwindSafe for MassProperties
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
. Read more
sourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcefn as_any(&self) -> &(dyn Any + 'static)
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. Read more
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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. Read more
sourceimpl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
sourcefn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
sourcefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
sourcefn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
sourcefn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more