Skip to main content

MassProperties

Struct MassProperties 

Source
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: f64

Mass, kg.

§cg_m: DVec3

Center of mass in body axes, m from the frame origin.

§inertia_kg_m2: DMat3

Inertia tensor about the center of mass, in body axes, kg·m².

Implementations§

Source§

impl MassProperties

Source

pub const ZERO: Self

No mass, at the origin.

Source

pub fn point(mass_kg: f64, position_m: DVec3) -> Self

A point mass at position_m.

Source

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).

Source

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.

Source

pub fn inertia_about(&self, point_m: DVec3) -> DMat3

The inertia tensor about point_m instead of the center of mass (parallel-axis theorem).

Source

pub fn translated(&self, offset_m: DVec3) -> Self

The same body moved by offset_m.

Source

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.

Source

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.

Source

pub fn rotated(&self, rotation: DQuat) -> Self

The same body turned by rotation about the frame origin: cg' = R cg, I' = R I Rᵀ.

Source

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).

Source

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.

Source

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).

Source

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).

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> MassProperties

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for MassProperties

Source§

impl Debug for MassProperties

Source§

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

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

impl Default for MassProperties

Source§

fn default() -> Self

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

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

Source§

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

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

impl PartialEq for MassProperties

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for MassProperties

Source§

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

Serialize this value into the given Serde serializer. Read more
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToOwned for T
where T: Clone,

Source§

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>,

Source§

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>,

Source§

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.