pub struct MassProperties {
pub mass_kg: f64,
pub cg_m: DVec3,
pub inertia_kg_m2: DMat3,
}Expand description
Mass, center of mass and inertia tensor about the center of mass, in body axes.
Fields§
§mass_kg: f64Mass, kg.
cg_m: DVec3Center of mass in body axes, m from the frame origin.
inertia_kg_m2: DMat3Inertia tensor about the center of mass, in body axes, kg·m².
Implementations§
Source§impl MassProperties
impl MassProperties
Sourcepub fn axisymmetric(
mass_kg: f64,
cg_m: DVec3,
axial_kg_m2: f64,
transverse_kg_m2: f64,
) -> Self
pub fn axisymmetric( mass_kg: f64, cg_m: DVec3, axial_kg_m2: f64, transverse_kg_m2: f64, ) -> Self
A body symmetric about a line parallel to z through cg_m, with moment of inertia
axial about that line and transverse about any perpendicular line through the center:
the tensor diag(I_t, I_t, I_a).
Sourcepub fn from_motor_element(element: &MassElement, nozzle_z_m: f64) -> Self
pub fn from_motor_element(element: &MassElement, nozzle_z_m: f64) -> Self
A motor-crate mass element on the body axis. The element’s axial coordinate runs toward the
nose like z, so a nozzle exit at body z = nozzle_z_m puts the element’s center at
nozzle_z_m + element.cg_m.
Sourcepub fn inertia_about(&self, point_m: DVec3) -> DMat3
pub fn inertia_about(&self, point_m: DVec3) -> DMat3
The inertia tensor about point_m instead of the center of mass (parallel-axis theorem).
Sourcepub fn translated(&self, offset_m: DVec3) -> Self
pub fn translated(&self, offset_m: DVec3) -> Self
The same body moved by offset_m.
Sourcepub fn with_part_moved(&self, part: &MassProperties, offset_m: DVec3) -> Self
pub fn with_part_moved(&self, part: &MassProperties, offset_m: DVec3) -> Self
This body with one of its parts, part, moved by offset_m inside it: a ballast weight
slid along the airframe, say. The mass is unchanged; with M the whole’s mass, m the
part’s, c its center before the move and δ the offset,
cg' = cg + m δ / M
I' = I_{cg'} + m [(|c + δ − cg'|² E − (c + δ − cg')(c + δ − cg')ᵀ) − (|c − cg'|² E − (c − cg')(c − cg')ᵀ)]where I_{cg'} is this body’s inertia about the new center (parallel axis): the part’s
point contribution about the new center is taken out where it was and put back where it is.
Its own inertia about its center moves with it unchanged, so it cancels. part must be a
part of this body; nothing checks that it is.
Sourcepub fn without_part(&self, part: &MassProperties) -> Self
pub fn without_part(&self, part: &MassProperties) -> Self
This body with one of its parts, part, taken out: a ballast weight or a payload released
in flight. With M the whole’s mass and cg its center, m the part’s mass, c its
center and I_p its own inertia about c,
M' = M − m
cg' = (M cg − m c) / M'
I' = I_{cg'} − (I_p + m (|c − cg'|² E − (c − cg')(c − cg')ᵀ))where I_{cg'} is this body’s inertia about the new center (parallel axis), and the
bracket is the part’s about it: Self::combine run backwards. part must be a part of
this body, lighter than it; nothing checks that it is.
Sourcepub fn rotated(&self, rotation: DQuat) -> Self
pub fn rotated(&self, rotation: DQuat) -> Self
The same body turned by rotation about the frame origin: cg' = R cg, I' = R I Rᵀ.
Sourcepub fn rolled(&self, angle_rad: f64) -> Self
pub fn rolled(&self, angle_rad: f64) -> Self
The same body rolled by angle_rad about the body z axis (right-handed: x toward y).
Sourcepub fn scaled(&self, factor: f64) -> Self
pub fn scaled(&self, factor: f64) -> Self
The same body with its mass scaled by factor and its shape unchanged: the inertia scales
with the mass.
Sourcepub fn copied(body: Self, offsets_m: &[[f64; 2]]) -> Self
pub fn copied(body: Self, offsets_m: &[[f64; 2]]) -> Self
Copies of body, one moved by each [x, y] of offsets_m across the axis, combined into
one rigid body: a cluster’s tubes, or what each of them holds. One copy that is not moved
is body itself, bit for bit; no offsets at all is no body (zero mass).
Sourcepub fn placed(body: Self, places: &[Placement]) -> Self
pub fn placed(body: Self, places: &[Placement]) -> Self
Copies of body, one at each of places, combined into one rigid body: a cluster’s tubes
or a pod set’s pods, or what each of them holds. Each copy is body rolled by its place’s
angle about the body’s axis, then moved across it by its offset, so each carries its own
parallel-axis term. One place that neither moves nor turns is body itself, bit for bit;
no places at all is no body (zero mass).
Sourcepub fn combine<'a>(
parts: impl IntoIterator<Item = &'a MassProperties> + Clone,
) -> Self
pub fn combine<'a>( parts: impl IntoIterator<Item = &'a MassProperties> + Clone, ) -> Self
The bodies combined into one rigid body.
With zero total mass the center is the plain average of the parts’ centers (the origin with no parts) and the tensors are summed, so massless placeholders stay finite.
Sourcepub fn principal_moments_kg_m2(&self) -> [f64; 3]
pub fn principal_moments_kg_m2(&self) -> [f64; 3]
The principal moments of inertia about the center of mass, ascending: the eigenvalues of the tensor.
Sourcepub fn validate(&self) -> Result<(), DesignError>
pub fn validate(&self) -> Result<(), DesignError>
Checks that this could be a real body: finite, non-negative mass; finite center; a
symmetric tensor (to 1e-9 of its largest entry) whose principal moments are non-negative
and obey the triangle inequality I_1 + I_2 ≥ I_3 (to the same tolerance), and that is zero
when the mass is.
§Errors
DesignError::Domain for a bad mass or center, DesignError::UnphysicalInertia for a
bad tensor.
Trait Implementations§
Source§impl Clone for MassProperties
impl Clone for MassProperties
Source§fn clone(&self) -> MassProperties
fn clone(&self) -> MassProperties
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MassProperties
Source§impl Debug for MassProperties
impl Debug for MassProperties
Source§impl Default for MassProperties
impl Default for MassProperties
Source§impl<'de> Deserialize<'de> for MassProperties
impl<'de> Deserialize<'de> for MassProperties
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for MassProperties
impl PartialEq for MassProperties
Source§fn eq(&self, other: &MassProperties) -> bool
fn eq(&self, other: &MassProperties) -> bool
self and other values to be equal, and is used by ==.