Skip to main content

FreeBody

Struct FreeBody 

Source
pub struct FreeBody { /* private fields */ }
Expand description

A rigid body of fixed mass and inertia.

Its State is the center of mass’s, where a rocket’s is its nose tip’s: the position and velocity are the center of mass’s in the launch frame, the attitude takes the body’s axes to the launch frame’s, and the body rates are relative to the launch frame, in body axes. The body’s axes are whatever the inertia is given in; no axis is a nose.

It serializes as its mass_kg and inertia_kg_m2 and is checked again when read, so a body that FreeBody::new would refuse can’t be read from a file either.

Implementations§

Source§

impl FreeBody

Source

pub fn new(mass_kg: f64, inertia_kg_m2: DMat3) -> Result<Self, SimError>

A body of mass mass_kg and inertia tensor inertia_kg_m2 about its center of mass, in its own axes, kg·m².

The tensor must be symmetric exactly, to the last bit. One computed by parts, such as a rocket’s inertia moved to its center of mass, is often off by rounding; the caller averages it with its transpose first, (I + Iᵀ)/2, so that what is flown is what the caller chose, not a repair made here.

§Errors

SimError::Domain naming what was refused: a mass that is not finite and positive (FREE_BODY_MASS_REFUSED), or an inertia with an entry that is not finite (FREE_BODY_INERTIA_NOT_FINITE), that is not symmetric (FREE_BODY_INERTIA_NOT_SYMMETRIC) or that is not positive definite (FREE_BODY_INERTIA_NOT_POSITIVE).

Source

pub fn mass_kg(&self) -> f64

The mass, kg.

Source

pub fn inertia_kg_m2(&self) -> DMat3

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

Source

pub fn derivative( &self, environment: &Environment, loads: &dyn FreeBodyLoads, y: &[f64; 13], ) -> Result<[f64; 13], SimError>

The state’s time derivative in environment under the caller’s loads, in State::to_array’s order: the weight and the Coriolis force at the center of mass, as a rocket’s flight takes them, and the caller’s force and moment, through the flight’s free-motion equations.

§Errors

SimError::Domain for an attitude quaternion whose norm is zero or not finite, or with FREE_BODY_LOAD_NOT_FINITE for a load that is not finite; SimError::Core if the Earth model refuses the position; whatever the environment refuses of the air or the wind there; and whatever loads refuses.

Source

pub fn fly( &self, environment: &Environment, loads: &dyn FreeBodyLoads, method: Method, t0_s: f64, state: State, times_s: &[f64], ) -> Result<Vec<State>, SimError>

Flies the body in environment under the caller’s loads from state at t0_s and gives its state at each of times_s, read from the steps’ dense output as a flight’s recorder reads its samples. The times don’t shape the steps, but for the last, where the integration stops. Nothing ends the flight early: the ground is not looked for.

§Errors

SimError::Domain with FREE_BODY_TIME_REFUSED for a sample time that is not finite, is before t0_s or is before the one ahead of it; SimError::Settings for a bad method or a start that is not finite; whatever Self::derivative refuses; and SimError::Integration if the integration fails, the step limit included.

Trait Implementations§

Source§

impl Clone for FreeBody

Source§

fn clone(&self) -> FreeBody

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 Debug for FreeBody

Source§

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

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

impl<'de> Deserialize<'de> for FreeBody

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 FreeBody

Source§

fn eq(&self, other: &FreeBody) -> 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 FreeBody

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 FreeBody

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.