Documentation 
Implement quaternion representation of sixdegreesoffreedom equations of motion of simple variable mass in Earthcentered Earthfixed (ECEF) coordinates
The Simple Variable Mass 6DOF ECEF (Quaternion) block considers the rotation of a Earthcentered Earthfixed (ECEF) coordinate frame (X_{ECEF}, Y_{ECEF}, Z_{ECEF}) about an Earthcentered inertial (ECI) reference frame (X_{ECI}, Y_{ECI}, Z_{ECI}). The origin of the ECEF coordinate frame is the center of the Earth, additionally the body of interest is assumed to be rigid, an assumption that eliminates the need to consider the forces acting between individual elements of mass. The representation of the rotation of ECEF frame from ECI frame is simplified to consider only the constant rotation of the ellipsoid Earth (ω_{e} ) including an initial celestial longitude (L_{G}(0)). This excellent approximation allows the forces due to the Earth's complex motion relative to the "fixed stars" to be neglected.
The translational motion of the ECEF coordinate frame is given below, where the applied forces [F_{x} F_{y} F_{z}]^{T} are in the body frame. Vre_{b} is the relative velocity in the wind axes at which the mass flow ($$\dot{m}$$) is ejected or added to the body axes.
$$\begin{array}{c}{\overline{F}}_{b}=\left[\begin{array}{c}{F}_{x}\\ {F}_{y}\\ {F}_{z}\end{array}\right]=m\left({\dot{\overline{V}}}_{b}+{\overline{\omega}}_{b}\times {\overline{V}}_{b}+DC{M}_{bf}{\overline{\omega}}_{e}\times {\overline{V}}_{b}+DC{M}_{bf}\left({\overline{\omega}}_{e}\times \left({\overline{\omega}}_{e}\times {\overline{X}}_{f}\right)\right)\right)\\ +\dot{m}\left(\overline{V}r{e}_{b}+DC{M}_{bf}\left({\overline{\omega}}_{e}\times {\overline{X}}_{f}\right)\right)\end{array}$$
where the change of position in ECEF $${\dot{\overline{x}}}_{f}({\dot{\overline{x}}}_{i})$$ is calculated by
$${\dot{\overline{x}}}_{f}=DC{M}_{fb}{\overline{V}}_{b}$$
and the velocity of the body with respect to ECEF frame, expressed in body frame $$({\overline{V}}_{b})$$, angular rates of the body with respect to ECI frame, expressed in body frame $$({\overline{\omega}}_{b})$$. Earth rotation rate $$({\overline{\omega}}_{e})$$, and relative angular rates of the body with respect to northeastdown (NED) frame, expressed in body frame $$({\overline{\omega}}_{rel})$$ are defined as
$$\begin{array}{l}{\overline{V}}_{b}=\left[\begin{array}{c}u\\ v\\ w\end{array}\right]\text{}{\overline{\omega}}_{rel}=\left[\begin{array}{c}p\\ q\\ r\end{array}\right]\text{}{\overline{\omega}}_{e}=\left[\begin{array}{c}0\\ 0\\ {\omega}_{e}\end{array}\right]\\ \\ {\overline{\omega}}_{b}={\overline{\omega}}_{rel}+DC{M}_{bf}{\overline{\omega}}_{e}+DC{M}_{be}{\overline{\omega}}_{ned}\\ \\ {\overline{\omega}}_{ned}=\left[\begin{array}{c}\dot{l}\mathrm{cos}\mu \\ \dot{\mu}\\ \dot{l}\mathrm{sin}\mu \end{array}\right]=\left[\begin{array}{c}{V}_{E}/\left(N+h\right)\\ {V}_{N}/\left(M+h\right)\\ {V}_{E}\mathrm{tan}\mu /\left(N+h\right)\end{array}\right]\end{array}$$
The rotational dynamics of the body defined in bodyfixed frame are given below, where the applied moments are [L M N]^{T}, and the inertia tensor I is with respect to the origin O.
$$\begin{array}{l}{\overline{M}}_{b}=\left[\begin{array}{c}L\\ M\\ N\end{array}\right]=\overline{I}{\dot{\overline{\omega}}}_{b}+{\overline{\omega}}_{b}\times (\overline{I}{\overline{\omega}}_{b})+\dot{I}{\overline{\omega}}_{b}\\ \\ I=\left[\begin{array}{ccc}{I}_{xx}& {I}_{xy}& {I}_{xz}\\ {I}_{yx}& {I}_{yy}& {I}_{yz}\\ {I}_{zx}& {I}_{zy}& {I}_{zz}\end{array}\right]\end{array}$$
The inertia tensor is determined using a table lookup which linearly interpolates between I_{full} and I_{empty} based on mass (m). The rate of change of the inertia tensor is estimated by the following equation.
$$\dot{I}=\frac{{I}_{full}{I}_{empty}}{{m}_{full}{m}_{empty}}\dot{m}$$
The integration of the rate of change of the quaternion vector is given below.
$$\left[\begin{array}{c}{\dot{q}}_{0}\\ {\dot{q}}_{1}\\ {\dot{q}}_{2}\\ {\dot{q}}_{3}\end{array}\right]=\raisebox{1ex}{$1$}\!\left/ \!\raisebox{1ex}{$2$}\right.\left[\begin{array}{cccc}0& {\omega}_{b}\left(1\right)& {\omega}_{b}\left(2\right)& {\omega}_{b}\left(3\right)\\ {\omega}_{b}\left(1\right)& 0& {\omega}_{b}\left(3\right)& {\omega}_{b}\left(2\right)\\ {\omega}_{b}\left(2\right)& {\omega}_{b}\left(3\right)& 0& {\omega}_{b}\left(1\right)\\ {\omega}_{b}\left(3\right)& {\omega}_{b}\left(2\right)& {\omega}_{b}\left(1\right)& 0\end{array}\right]\left[\begin{array}{c}{q}_{0}\\ {q}_{1}\\ {q}_{2}\\ {q}_{3}\end{array}\right]$$
Specifies the input and output units:
Units  Forces  Moment  Acceleration  Velocity  Position  Mass  Inertia 

Metric (MKS)  Newton  Newton meter  Meters per second squared  Meters per second  Meters  Kilogram  Kilogram meter squared 
English (Velocity in ft/s)  Pound  Foot pound  Feet per second squared  Feet per second  Feet  Slug  Slug foot squared 
English (Velocity in kts)  Pound  Foot pound  Feet per second squared  Knots  Feet  Slug  Slug foot squared 
Select the type of mass to use:
Fixed  Mass is constant throughout the simulation (see 6DOF ECEF (Quaternion)). 
Simple Variable  Mass and inertia vary linearly as a function of mass rate. 
Custom Variable  Mass and inertia variations are customizable (see Custom Variable Mass 6DOF ECEF (Quaternion)). 
The Simple Variable selection conforms to the previously described equations of motion.
The threeelement vector for the initial location of the body in the geodetic reference frame. Latitude and longitude values can be any value. However, latitude values of +90 and 90 may return unexpected values because of singularity at the poles.
The threeelement vector containing the initial velocity of the body with respect to the ECEF frame, expressed in the body frame.
The threeelement vector containing the initial Euler rotation angles [roll, pitch, yaw], in radians. Euler rotation angles are those between the body and NED coordinate systems.
The threeelement vector for the initial angular rates of the body with respect to the NED frame, expressed the body frame, in radians per second.
The mass of the rigid body.
A scalar value for the empty mass of the body.
A scalar value for the full mass of the body.
A 3by3 inertia tensor matrix for the empty inertia of the body.
A 3by3 inertia tensor matrix for the full inertia of the body.
Select this check box to add a mass flow relative velocity port. This is the relative velocity at which the mass is accreted or ablated.
Specifies the planet model to use: Custom or Earth (WGS84).
Specifies the radius of the planet at its equator. The units of the equatorial radius parameter should be the same as the units for ECEF position. This option is only available when Planet model is set to Custom.
Specifies the flattening of the planet. This option is only available when Planet model is set to Custom.
Specifies the scalar rotational rate of the planet in rad/s. This option is only available when Planet model is set to Custom.
Specifies the source of Greenwich meridian's initial celestial longitude:
Internal  Use celestial longitude value from Celestial longitude of Greenwich. 
External  Use external input for celestial longitude value. 
The initial angle between Greenwich meridian and the xaxis of the ECI frame. This parameter appears if you set Celestial longitude of Greenwich source to Internal.
Input  Dimension Type  Description 

First  Vector  Contains the three applied forces in bodyfixed axes. 
Second  Vector  Contains the three applied moments in bodyfixed axes. 
Third  Scalar  Contains one or more rates of change of mass (positive if accreted, negative if ablated). 
Fourth (Optional)  Threeelement vector  Contains one or more relative velocities at which the mass is accreted to or ablated from the bodyfixed axes. 
Output  Dimension Type  Description 

First  Threeelement vector  Contains the velocity of body respect to ECEF frame, expressed in ECEF frame. 
Second  Threeelement vector  Contains the position in the ECEF reference frame. 
Third  Threeelement vector  Contains the position in geodetic latitude, longitude and altitude, in degrees, degrees and selected units of length respectively. 
Fourth  Threeelement vector  Contains the body rotation angles [roll, pitch, yaw], in radians. Euler rotation angles are those between body and NED coordinate systems. 
Fifth  3by3 matrix  Applies to the coordinate transformation from ECI axes to bodyfixed axes. 
Sixth  3by3 matrix  Applies to the coordinate transformation from NED axes to bodyfixed axes. 
Seventh  3by3 matrix  Applies to the coordinate transformation from ECEF axes to NED axes. 
Eighth  Threeelement vector  Contains the velocity of body with respect to ECEF frame, expressed in body frame. 
Ninth  Threeelement vector  Contains the relative angular rates of body with respect to NED frame, expressed in body frame, in radians per second. 
Tenth  Threeelement vector  Contains the angular rates of the body with respect to ECI frame, expressed in body frame, in radians per second. 
Eleventh  Threeelement vector  Contains the angular accelerations of the body with respect to ECI frame, expressed in body frame, in radians per second squared. 
Twelfth  Threeelement vector  Contains the accelerations in bodyfixed axes. 
Thirteenth  Scalar  Is an element containing a flag for fuel tank status:

This implementation assumes that the applied forces are acting at the center of gravity of the body.
This implementation generates a geodetic latitude that lies between ±90 degrees, and longitude that lies between ±180 degrees. Additionally, the MSL altitude is approximate.
The Earth is assumed to be ellipsoidal. By setting flattening to 0.0, a spherical planet can be achieved. The Earth's precession, nutation, and polar motion are neglected. The celestial longitude of Greenwich is Greenwich Mean Sidereal Time (GMST) and provides a rough approximation to the sidereal time.
The implementation of the ECEF coordinate system assumes that the origin is at the center of the planet, the xaxis intersects the Greenwich meridian and the equator, the zaxis is the mean spin axis of the planet, positive to the north, and the yaxis completes the righthand system.
The implementation of the ECI coordinate system assumes that the origin is at the center of the planet, the xaxis is the continuation of the line from the center of the Earth through the center of the Sun toward the vernal equinox, the zaxis points in the direction of the mean equatorial plane's north pole, positive to the north, and the yaxis completes the righthand system.
Stevens, B. L., and F. L. Lewis, Aircraft Control and Simulation, Second Edition, John Wiley & Sons, New York, 2003.
McFarland, Richard E., A Standard Kinematic Model for Flight simulation at NASAAmes, NASA CR2497.
"Supplement to Department of Defense World Geodetic System 1984 Technical Report: Part I  Methods, Techniques and Data Used in WGS84 Development," DMA TR8350.2A.
6th Order Point Mass (Coordinated Flight)
Custom Variable Mass 6DOF (Euler Angles)
Custom Variable Mass 6DOF (Quaternion)
Custom Variable Mass 6DOF ECEF (Quaternion)
Custom Variable Mass 6DOF Wind (Quaternion)
Custom Variable Mass 6DOF Wind (Wind Angles)
Simple Variable Mass 6DOF (Euler Angles)
Simple Variable Mass 6DOF (Quaternion)