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
impl FreeBody
Sourcepub fn new(mass_kg: f64, inertia_kg_m2: DMat3) -> Result<Self, SimError>
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).
Sourcepub fn inertia_kg_m2(&self) -> DMat3
pub fn inertia_kg_m2(&self) -> DMat3
The inertia tensor about the center of mass, in body axes, kg·m².
Sourcepub fn derivative(
&self,
environment: &Environment,
loads: &dyn FreeBodyLoads,
y: &[f64; 13],
) -> Result<[f64; 13], SimError>
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.
Sourcepub fn fly(
&self,
environment: &Environment,
loads: &dyn FreeBodyLoads,
method: Method,
t0_s: f64,
state: State,
times_s: &[f64],
) -> Result<Vec<State>, SimError>
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.