Skip to main content

Coordinate Systems & Transformations

This section describes the coordinate reference frames used by the Spaceflight Dynamics Framework and the mathematical transformations implemented in the CoordinateTransformer class.

The framework uses a single simulation truth frame for physical propagation and derives all other coordinate representations from this state. This prevents conflicting state representations while still providing specialized frames for guidance, navigation, telemetry, visualization, and future orbital operations.


State Ownership and Frame Hierarchy

The translational state of the spacecraft is propagated in the Moon-Centered Inertial frame. The corresponding state vector is the single source of truth for spacecraft motion.

x=[rMCI,vMCI,qIB,ωSBF] \mathbf{x} = \left[ \mathbf{r}_{MCI}, \mathbf{v}_{MCI}, q_{IB}, \boldsymbol{\omega}_{SBF} \right]

Where:
rMCI\mathbf{r}_{MCI} is the spacecraft position in MCI [m]
vMCI\mathbf{v}_{MCI} is the spacecraft velocity in MCI [m/s]
qIBq_{IB} is the body-to-inertial attitude quaternion
ωSBF\boldsymbol{\omega}_{SBF} is the angular velocity expressed in the spacecraft body frame [rad/s]

All other frames are derived views:

MCI
├── MCMF
│   ├── MSC
│   └── ENU
│
├── LVLH
│
└── SBF

Reference Frame Definitions

MCI — Moon-Centered Inertial

The Moon-Centered Inertial frame is the primary physics frame of SDF. All translational dynamics are integrated in this frame.

Origin: Center of the Moon
Axes:
• +Z = Lunar North Pole
• +X = Prime Meridian at reference epoch t0t_0
• +Y = +Z×+X+Z \times +X

MCI is moon-centered, inertial, non-rotating, and right-handed.

MCMF — Moon-Centered Moon-Fixed

The Moon-Centered Moon-Fixed frame is attached to the lunar body and rotates with the Moon. It is used for surface-fixed locations, landing sites, and lunar geography.

Origin: Center of the Moon
Axes:
• +Z = Lunar North Pole
• +X = Current Prime Meridian
• +Y = +Z×+X+Z \times +X

MCMF is moon-centered, rotating, surface-fixed, non-inertial, and right-handed.

MSC — Moon Surface Coordinates

Moon Surface Coordinates provide a geodetic representation of a lunar surface or near-surface location.

MSC is not a Cartesian frame. It is represented by latitude, longitude, and altitude:

MSC=(ϕ,λ,h) MSC = \left( \phi, \lambda, h \right)

Where:
ϕ\phi is lunar latitude [rad]
λ\lambda is lunar longitude [rad]
hh is altitude above the mean lunar radius [m]

ENU — East-North-Up

ENU is a local tangent frame attached to a mission reference point, typically the landing site. It is used for landing guidance, local navigation, and surface-relative telemetry.

Origin: Landing site
Axes:
• +X = East
• +Y = North
• +Z = Up

ENU is right-handed and locally defined. Its orientation depends on the chosen surface reference point.

LVLH — Local Vertical Local Horizontal

The LVLH frame is a spacecraft-centered orbital frame. It is useful for relative motion, rendezvous, docking, and orbital guidance.

Origin: Current spacecraft position
Axes:
• +X = Forward
• +Y = Right
• +Z = Down, toward the lunar center

The current implementation expresses LVLH velocities as projected relative velocities. Full rotating-frame velocity and acceleration terms are reserved for future high-fidelity dynamics.

SBF — Spacecraft Body Frame

The Spacecraft Body Frame is rigidly attached to the spacecraft and rotates with its attitude. It is the primary frame for propulsion, RCS, sensors, and control-related quantities.

Origin: Spacecraft center of mass
Axes:
• +X = Forward
• +Y = Right
• +Z = Down

Engine directions and RCS force directions are expressed in SBF. The current propulsion pipeline computes thrust in SBF and rotates it into MCI before passing it to the physics model.


MCI to MCMF Transformation

The MCMF frame rotates with the Moon relative to the inertial MCI frame. The lunar rotation angle is computed as:

θ(t)=ωMt \theta(t) = \omega_M t

Where:
ωM\omega_M is the lunar sidereal rotation rate [rad/s]
tt is simulation time [s]

The corresponding rotation quaternion is:

qM(t)=[cos(θ2),0,0,sin(θ2)] q_M(t) = \left[ \cos\left(\frac{\theta}{2}\right), 0, 0, \sin\left(\frac{\theta}{2}\right) \right]

The position transformation is:

rMCMF=qMrMCIqM1 \mathbf{r}_{MCMF} = q_M \, \mathbf{r}_{MCI} \, q_M^{-1}

Since the target frame is rotating, the velocity transformation includes the transport term caused by the lunar angular velocity:

vMCMF=qM(vMCIωM×rMCI)qM1 \mathbf{v}_{MCMF} = q_M \left( \mathbf{v}_{MCI} - \boldsymbol{\omega}_M \times \mathbf{r}_{MCI} \right) q_M^{-1}

with:

ωM=[0,0,ωM]T \boldsymbol{\omega}_M = \left[ 0, 0, \omega_M \right]^T

MCMF to MCI Transformation

The inverse transformation rotates a Moon-fixed state back into the inertial frame. The inverse quaternion is used for the position mapping:

rMCI=qM1rMCMFqM \mathbf{r}_{MCI} = q_M^{-1} \, \mathbf{r}_{MCMF} \, q_M

The inertial velocity is reconstructed by adding the rotating-frame velocity contribution:

vMCI=qM1(vMCMF+ωM×rMCMF)qM \mathbf{v}_{MCI} = q_M^{-1} \left( \mathbf{v}_{MCMF} + \boldsymbol{\omega}_M \times \mathbf{r}_{MCMF} \right) q_M

MCMF to Moon Surface Coordinates

A Cartesian position in the Moon-fixed frame can be converted into geodetic Moon Surface Coordinates.

Given:

rMCMF=[x,y,z]T \mathbf{r}_{MCMF} = \left[ x, y, z \right]^T

The radial distance is:

r=rMCMF r = ||\mathbf{r}_{MCMF}||

Latitude, longitude, and altitude are computed as:

ϕ=arcsin(zr) \phi = \arcsin \left( \frac{z}{r} \right)
λ=atan2(y,x) \lambda = \operatorname{atan2}(y,x)
h=rRM h = r - R_M

Where RMR_M is the mean lunar reference radius.


Moon Surface Coordinates to MCMF

The inverse mapping reconstructs the Moon-fixed Cartesian position from latitude, longitude, and altitude.

r=RM+h r = R_M + h
x=rcosϕcosλ x = r \cos\phi \cos\lambda
y=rcosϕsinλ y = r \cos\phi \sin\lambda
z=rsinϕ z = r \sin\phi

The resulting velocity is initialized as zero in MCMF, because a fixed surface location is stationary in the Moon-fixed frame.


ENU Frame Construction

The ENU frame is constructed from a reference state expressed in MCMF. In the current simulation, this reference state is typically the mission landing site.

The local up direction is the normalized radial direction:

u^=roriginrorigin \hat{\mathbf{u}} = \frac{ \mathbf{r}_{origin} }{ ||\mathbf{r}_{origin}|| }

A global reference axis is selected to construct the local tangent plane. Under nominal conditions, the lunar rotation axis is used:

k^=[0,0,1]T \hat{\mathbf{k}} = \left[ 0, 0, 1 \right]^T

The east and north directions are computed as:

e^=k^×u^k^×u^ \hat{\mathbf{e}} = \frac{ \hat{\mathbf{k}} \times \hat{\mathbf{u}} }{ || \hat{\mathbf{k}} \times \hat{\mathbf{u}} || }
n^=u^×e^ \hat{\mathbf{n}} = \hat{\mathbf{u}} \times \hat{\mathbf{e}}

Near the lunar poles, the implementation switches to a fallback reference axis to avoid singularities caused by nearly parallel vectors.


MCMF to ENU Transformation

To express a Moon-fixed spacecraft state in the local ENU frame, the relative vector from the ENU origin to the spacecraft is projected onto the ENU basis vectors.

Δr=rtargetrorigin \Delta\mathbf{r} = \mathbf{r}_{target} - \mathbf{r}_{origin}
rENU=[Δre^,Δrn^,Δru^]T \mathbf{r}_{ENU} = \left[ \Delta\mathbf{r}\cdot\hat{\mathbf{e}}, \Delta\mathbf{r}\cdot\hat{\mathbf{n}}, \Delta\mathbf{r}\cdot\hat{\mathbf{u}} \right]^T

The same projection is applied to relative velocity:

Δv=vtargetvorigin \Delta\mathbf{v} = \mathbf{v}_{target} - \mathbf{v}_{origin}
vENU=[Δve^,Δvn^,Δvu^]T \mathbf{v}_{ENU} = \left[ \Delta\mathbf{v}\cdot\hat{\mathbf{e}}, \Delta\mathbf{v}\cdot\hat{\mathbf{n}}, \Delta\mathbf{v}\cdot\hat{\mathbf{u}} \right]^T

ENU to MCMF Transformation

The inverse transformation reconstructs a Moon-fixed Cartesian state from local ENU coordinates and the stored ENU frame basis.

rMCMF=rorigin+xENUe^+yENUn^+zENUu^ \mathbf{r}_{MCMF} = \mathbf{r}_{origin} + x_{ENU}\hat{\mathbf{e}} + y_{ENU}\hat{\mathbf{n}} + z_{ENU}\hat{\mathbf{u}}
vMCMF=vorigin+vxe^+vyn^+vzu^ \mathbf{v}_{MCMF} = \mathbf{v}_{origin} + v_x\hat{\mathbf{e}} + v_y\hat{\mathbf{n}} + v_z\hat{\mathbf{u}}

LVLH Frame Construction

The LVLH frame is constructed from the current inertial spacecraft state. It is centered on the spacecraft and aligned with the local orbital geometry.

The down direction points toward the Moon center:

d^=rr \hat{\mathbf{d}} = - \frac{ \mathbf{r} }{ ||\mathbf{r}|| }

The orbital angular momentum vector is:

h=r×v \mathbf{h} = \mathbf{r} \times \mathbf{v}

The right direction is defined as:

y^LVLH=hh \hat{\mathbf{y}}_{LVLH} = - \frac{ \mathbf{h} }{ ||\mathbf{h}|| }

The forward direction completes the right-handed basis:

x^LVLH=y^LVLH×z^LVLH \hat{\mathbf{x}}_{LVLH} = \hat{\mathbf{y}}_{LVLH} \times \hat{\mathbf{z}}_{LVLH}

with z^LVLH=d^\hat{\mathbf{z}}_{LVLH} = \hat{\mathbf{d}}.

If the angular momentum magnitude approaches zero, a fallback axis is used to avoid a degenerate frame definition.


MCI to LVLH Transformation

A target state is expressed in LVLH by projecting the relative inertial state onto the LVLH basis vectors.

Δr=rtargetrorigin \Delta\mathbf{r} = \mathbf{r}_{target} - \mathbf{r}_{origin}
rLVLH=[Δrx^LVLH,Δry^LVLH,Δrz^LVLH]T \mathbf{r}_{LVLH} = \left[ \Delta\mathbf{r}\cdot\hat{\mathbf{x}}_{LVLH}, \Delta\mathbf{r}\cdot\hat{\mathbf{y}}_{LVLH}, \Delta\mathbf{r}\cdot\hat{\mathbf{z}}_{LVLH} \right]^T

The same projection is currently applied to relative velocity. This represents projected relative velocity, not the complete time derivative in a rotating LVLH frame.


LVLH to MCI Transformation

The inverse transformation reconstructs an inertial state from LVLH coordinates using the stored LVLH basis vectors.

rMCI=rorigin+xLVLHx^LVLH+yLVLHy^LVLH+zLVLHz^LVLH \mathbf{r}_{MCI} = \mathbf{r}_{origin} + x_{LVLH}\hat{\mathbf{x}}_{LVLH} + y_{LVLH}\hat{\mathbf{y}}_{LVLH} + z_{LVLH}\hat{\mathbf{z}}_{LVLH}
vMCI=vorigin+vxx^LVLH+vyy^LVLH+vzz^LVLH \mathbf{v}_{MCI} = \mathbf{v}_{origin} + v_x\hat{\mathbf{x}}_{LVLH} + v_y\hat{\mathbf{y}}_{LVLH} + v_z\hat{\mathbf{z}}_{LVLH}

MCI to SBF Transformation

The spacecraft body frame is defined by the spacecraft attitude quaternion and the current spacecraft origin state.

The body-to-inertial quaternion is denoted:

qIB q_{IB}

To transform an inertial state into the spacecraft body frame, the inverse attitude quaternion is applied to the relative state:

rSBF=qIB1(rMCIrorigin)qIB \mathbf{r}_{SBF} = q_{IB}^{-1} \left( \mathbf{r}_{MCI} - \mathbf{r}_{origin} \right) q_{IB}
vSBF=qIB1(vMCIvorigin)qIB \mathbf{v}_{SBF} = q_{IB}^{-1} \left( \mathbf{v}_{MCI} - \mathbf{v}_{origin} \right) q_{IB}

SBF to MCI Transformation

The inverse transformation maps body-frame coordinates back into the inertial MCI frame.

rMCI=rorigin+qIBrSBFqIB1 \mathbf{r}_{MCI} = \mathbf{r}_{origin} + q_{IB} \mathbf{r}_{SBF} q_{IB}^{-1}
vMCI=vorigin+qIBvSBFqIB1 \mathbf{v}_{MCI} = \mathbf{v}_{origin} + q_{IB} \mathbf{v}_{SBF} q_{IB}^{-1}

Generic Vector Transformations

Some quantities represent free vectors rather than position states. Examples include thrust vectors, acceleration vectors, sensor axes, and force directions.

Such quantities are rotated between frames without applying a translational origin offset.

aSBF=qIB1aMCIqIB \mathbf{a}_{SBF} = q_{IB}^{-1} \mathbf{a}_{MCI} q_{IB}
aMCI=qIBaSBFqIB1 \mathbf{a}_{MCI} = q_{IB} \mathbf{a}_{SBF} q_{IB}^{-1}

This mechanism is used in the current thrust pipeline. Thrust is computed in SBF and rotated into MCI before it is passed to the physics model.


Implementation Characteristics

  • MCI remains the single translational truth frame.
  • MCMF is obtained by lunar rotation from MCI.
  • MSC is derived from Moon-fixed Cartesian coordinates.
  • ENU is generated from a local MCMF reference point.
  • LVLH is computed from instantaneous MCI position and velocity.
  • SBF is defined by spacecraft attitude and MCI origin state.
  • Generic vector transformations apply rotation only.