Orbital Mechanics

This is a deep dive into the fascinating topic of orbital mechanics: from the implementation of gravity simulators, to the mathematics which governs Keplerian orbits in the two-body problem.

Introduction

Gravity is one of the most familiar forces we experience, yet it remains one of the least understood. It is the silent architect shaping the trajectories of planets, stars, and galaxies, dictating the very structure and long-term evolution of the Universe. And yet, despite its importance, our understanding of gravity is still incomplete.

The position of stars and planets has not just captured our imagination: it literally shaped history, cultures, societies, and technologies. For millennia, people tried to explain how stars and planets move in the sky without falling. In the 17th century, Newton’s law of universal gravitation gave us the first mathematical framework to describe gravitational attraction, powerful enough to predict the motion of planets with remarkable accuracy. Centuries later, Einstein’s general relativity reframed gravity as the curvature of spacetime itself (pictured below), pushing our understanding and predictions to even greater precision.

Rendered by QuickLaTeX.com

More recently, alternative theories like Modified Newtonian Dynamics (MOND) attempt to reconcile our best models of gravity with the observed behaviours of galaxies and dark matter. And yet, the true nature of gravity, and the role it plays at a quantum level, still elude us.

📃 List of modern gravitational theories

Emergent complexity

Even within the familiar Newtonian picture, predicting the motion of bodies under gravity is far from straightforward. A two-body system has an elegant solution: orbits take the shape of ellipses, parabolas, or hyperbolas, perfectly described by Kepler’s laws. But adding just one more body transforms this fully deterministic system into a chaotic one, whose long-term behaviour cannot be fully predicted without simulating it first.

❓ How can a chaotic system be deterministic?

The equations that govern Newtonian gravity and Keplerian orbits quickly become transcendental, which in this case means we cannot write down a simple closed-form solution for arbitrary configurations.

This tension between simplicity and complexity is at the heart of orbital mechanics. With the right assumptions, the Universe’s vast clockwork reveals a geometric beauty. But step outside those assumptions, and prediction becomes a matter of numerical methods, approximation, and simulation.

❓ Why is the three-body problem unsolvable?

What you will learn…

In this article, we will build up the tools to understand and model orbits: from the basic laws of gravity, through the mathematics of Keplerian motion, to the algorithms that allow us to predict the position of a body at any given time.

  • ¶ Part 1: Modelling gravity
    • This section covers the two main techniques used to model gravity: simulations (physically correct, but unstable and very sensitive to measurement errors), and Keplerian orbits (highly simplified, but easy to predict).
  • ¶ Part 2: Understanding Keplerian orbits
    • This section covers the mathematical and geometrical foundations needed to describe elliptical orbits, their properties, and orbital elements (the parameters needed to describe them).
  • ¶ Part 3: Orbital prediction
    • This section provides a clear algorithm to find the position of a body in a Keplerian orbit, at any given time.
  • ¶ Part 4: Unbound orbits
    • This section explains how to model open orbits with parabolas and hyperbolas.

If you are interested in Astronomy and orbital mechanics, I would suggest checking the Exoplanet Catalogue, which shows animated renderings for all discovered exoplanetary systems.

Part 1: Modelling gravity

When it comes to predicting motion under gravity, there are really two very different approaches. The first is to simulate it directly: every object pulls on every other object, step by step, force by force. This is a close approximation to what happens in the real world, and it captures all the chaotic, emergent behaviour of gravitational systems. But it also comes with a cost. Rounding errors accumulate, orbits slowly drift, and the longer you run the simulation, the more it diverges from reality.

The second approach heavily relies on Mathematics and Geometry. Kepler showed that when only two bodies are present (the so-called two-body problem), orbits can only be in the shape of ellipses, parabolas, and hyperbolas. Moreover, the position of a body at any given time can be found using an equation, without the need to simulate the passage of time step by step. Predicting where something will be after a million years is just as fast as predicting where it will be tomorrow. But there’s a catch: these perfect solutions only exist in well-behaved scenarios, like a lone planet orbiting a star. The moment more bodies get involved, reality starts to deviate, and the predictions lose their accuracy after a few decades or centuries.

Let’s see both approaches in more detail.

Gravity simulation

Back in 1687, Isaac Newton published the Philosophiæ Naturalis Principia Mathematica, where he derived the law of universal gravitation. Newton sees gravity as an attractive force (F) between any two bodies with mass (m, and M):

Rendered by QuickLaTeX.com

which is governed by the following relationship:

(1)   \begin{equation*}  F = G \frac{M m}{r^2} \end{equation*}

where:

  • r: the distance between the bodies;
  • G: the gravitational constant.

❓ What is G?

❓ Why are both bodies subject to the same force?

Much of the complexity that we see in the structure of the universe is described by this equation.

Many computer simulations implement Newton’s law directly, and model the effect of gravity as the result of mutual forces between bodies. Below you can see a gravity simulation that runs directly in the browser:

💾 Full code

Thanks to its simplicity, there is no shortage of online simulators and games you can play with. A few years ago I even made one myself, called 0RBITALIS:

🎮 Interactive gravity simulations

Non-Keplerian orbits

Newtonian gravity simulations are powerful because they correctly model and predict most of the non-relativistic phenomena observed by Astronomers. They are used to simulate complex orbital mechanics that would otherwise be too difficult to model mathematically or solve analytically.

Gravitational slingshots, orbital precessions, tidal locking, Lagrange points, and orbital resonance, are some of the phenomena that emerge naturally from Newton’s law of universal gravitation.

❓ Orbital precession

❓ Orbital resonance

Simulating gravity is powerful, but it has its drawbacks. It is not usually possible to get answers to specific questions. How long before a comet will pass near Earth? When should a launch be scheduled to arrive on Mars at a specific date? What orbit requires the least amount of fuel to land on the Moon?

Without a solid mathematical understanding of orbital mechanics, the best we can do is to simulate a lot of different scenarios. But the chaotic nature of gravity means that the number of simulations needed grows exponentially, the longer we look into the future.

🪐 The Interplanetary Transport Network

The number of interactions also grows quadratically as a function of the number of simulated bodies. With 100 bodies, there are 10,000 forces at play; with 1,000 bodies, there are 1,000,000 forces. The complexity of a quadratic algorithm will quickly outgrow the computational power available.

Numerical integrations

The force of gravity is felt continuously, at all times. All computer simulations use numerical integration to update the state of their systems (positions, velocities, acceleration, forces, …) in discrete time steps (\Delta t).

There are many ways to approximate a continuous process through discrete steps: the most common ones are (in order of precision) the Euler integration, the leapfrog integration, and the Runge-Kutta method.

❓ Euler integration

❓ Leapfrog integration

❓ Runge-Kutta integration

You can read more about how those numerical techniques compare in Galaxy Simulator Parameters Define.

Regardless of the technique used, the results of a simulation will inevitably drift over time, due to the propagation (and potential amplification) of any error introduced. There are typically three sources of errors:

  • Temporal accuracy: the longer the timestep used, the less accurate the simulation will become;
  • Uncertain measures: the initial parameters of the system (masses, velocities, distances, …) are the result of inaccurate measurements;
  • Fixed-precision arithmetic: floats and doubles, commonly used to store decimal numbers, have a limited precision.

The introduction of these errors in the simulation typically results in poor conservation of energy or angular momentum. In former results in orbits eventually spiralling in or out; the latter in their steady precession.

❓ Why is energy conserved in stable orbits?

Keplerian Orbits

A Keplerian orbit is the exact analytical solution to the Newtonian two-body problem under the following conditions:

  • there are only two bodies in the system;
  • the bodies are point-like (all of their mass is condensed in a single point);
  • there are no relativistic effects (the effect of gravity is instantaneous);
  • there are no external forces or perturbations of any kind.

The result is that:

  • the motion occurs in a fixed plane (the orbital plane);
  • the position of a body at any time can be determined directly;
  • the orbit is shaped like a conic section (either a circle, ellipse, parabola, or hyperbola).

Conic sections are classified based on a parameter called eccentricity:

  • e=0: circle (which is a type of ellipse);
  • e<1: ellipse;
  • e=1: parabola;
  • e>1: hyperbola.

🕹️ Use the slider to change the shape of the orbit through its eccentricity e:

e
0.5

The term orbit is generally used for circular and elliptical paths; the term trajectory is preferred for parabolic and hyperbolic paths, as they are unbound and do not close on themselves.

❓ Why are bound orbits elliptical?

❓ Radial trajectories

❓ What about two moving bodies?

Only six numbers (sometimes eight, depending on the context) are needed to fully characterise an orbit. There are many ways to choose them, with the most common being the ¶ Keplerian orbital elements.

Although four types of shapes are possible, many software programs only account for two: ellipses and hyperbolas. This is because circles are a special case of ellipses, and parabolas are the threshold between bound and unbound orbits, and real trajectories seldom have exactly e=1. We will take the same approach in this article, only covering bound (elliptical) and unbound (hyperbolic) paths.

Improving predictions

It is not uncommon for software programs to also enhance the predictions of Keplerian orbits by accounting for the natural drift that orbits experience over time due to reciprocal perturbations.

❓ Centennial rates

Not many games use Keplerian orbits, due to the complexity associated with their maths. The most popular one that does so is Kerbal Space Program.

While the planets in KSP are following fixed Keplerian orbits, a spacecraft can perform manoeuvres to alter its trajectory. KSP notoriously handles that with a clever technique called patched conic approximation, which “switches” a satellite’s central body of reference to the most gravitationally dominant one.

❓ Sphere of influence

Part 2: Understanding Keplerian orbits

The mathematics that governs orbital mechanics can be tough to digest. This section provides a gentle introduction to the topic, starting with a simple example, and progressively adding more and more complexity.

Before we begin our journey into the mathematics of Keplerian orbits, it is worth remembering the final objective: being able to predict the position of a satellite at a given time.

When real orbits are studied, Astronomers register the position of central bodies in the sky, and how they change over time. Those observed orbits are sometimes far from the idealised conic sections imagined by Kepler. Astronomers have to “bridge” the connection between these two models, fitting imaginary perfect orbits onto their data, until they find something they can solve analytically.

In this article, we will follow the opposite process: going from the most mathematically well-behaved orbits, to the most complex ones. By doing this, we can start gently and introduce progressively more complexity as we delve deeper into the subject.

Deriving the Keplerian orbits

Circular orbits

To understand the equations that govern orbital trajectories, it is best to start with the simplest possible scenario. Let’s imagine a satellite in a perfectly circular orbit, always keeping at a fixed distance a from its central body.

❓ Why is the radius of the orbit called a and not r?

A satellite in a circular orbit revolves at a constant speed. Orbital velocities are typically difficult to measure directly, because estimating the size and distance of celestial bodies is non-trivial using telescopes. It is much easier to measure velocities indirectly, by observing the time a satellite takes to complete a full revolution: this is the orbital period T (sometimes also indicated with P).

🕹️ Use the slider to change the orbital period (T) of the circular orbit.

T
10
s

The orbit is prograde if the satellite moves counterclockwise; retrograde otherwise.

❓ Cartesian coordinates of a circle

Angular position

The position of a satellite can be measured in different ways, like the angle it makes along its orbit with respect to its central body (measured from the horizontal axis). Let’s call it \alpha, and confine it to the range \left[0, 360^\circ\right].

By using simple trigonometry, we can derive the position on the horizontal and vertical axes (p and q, respectively) as a function of the angle \alpha:

(15)   \begin{equation*}  \begin{align*} p &= a \cos{\alpha} \\ q &= a \sin{\alpha} \end{align*} \end{equation*}

\alpha
45
°

Equation (15) represents the parametric form of a circle centred at \left(0,0\right). If this looks unfamiliar to you, A gentle primer on 2D rotations should help you understand how (15) is derived.

Stretching circles

Geometrically speaking, ellipses are “stretched” circles. Scaling the vertical axis down is sufficient to turn the circle defined by (15) into an ellipse:

(16)   \begin{equation*}  \begin{align*} p &= a \cos{\alpha} \\ q &= {\color{red}b} \sin{\alpha} \end{align*} \end{equation*}

a
125
b
100

Intuitively: a is the “original” radius, and b the “scaled” radius after the vertical axis has been “squished” down. As a convention, a\geq b, and they are called the semi-major axis and the semi-minor axis, respectively. All ellipses drawn from equation (16) are aligned with the axes.

How “stretched” an ellipse is depends on the ratio between a and b. The eccentricity (e) is an indirect measure of this deformation, and is defined as:

(17)   \begin{equation*}  e = \sqrt{1-\frac{b^2}{a^2}} \end{equation*}

When e=0, then a=b, and the ellipse becomes a circle. The ellipse gets progressively more elongated as e \rightarrow 1. When e \geq 1, the shape opens into either a parabola (e=1) or a hyperbola (e > 1).

❓ What does the eccentricity measure?

It is critical to understand that \alpha originally measured the angle of the satellite in a circular orbit. After the vertical axis was “squished” down (causing the respective semi-axis to go from a to b), the new angle of the satellite in its now elliptical orbit is \beta. The two angles are, in general, different. This can be seen in the diagram below, where the original position is in yellow, and the new one in red.

\alpha
45
°

The position of the original point on the circle (in yellow), and its new position projected on the ellipse (in red) are related via a linear transformation (the compression of the vertical axis). But their respective angles with the horizontal axis (\alpha and \beta) are not linearly related.

The angle that the satellite makes from the centre of the ellipse does not really have a name, as surprisingly, it does not play a role in the mathematical calculations.

❓ Orbital period and orbital shape

Centring on the focus

The equation (16) represents an ellipse centred in the middle. As a convention, all Keplerian orbits are centred around their central body. For elliptical orbits, that position is not their centre, but their primary focus.

❓ What are the foci of an ellipse?

❓ What is at the secondary focus?

❓ Why the word “focus”?

To fix that, we need to shift the ellipse defined by (16) back to the left, so that its primary focus lands on \left(0,0\right). The distance from the centre of the ellipse to the main focus is a e (since e represents how far along a the focus is), so we can subtract that from the first equation:

(21)   \begin{equation*}  \begin{align*} p &= a \cos{\alpha} - a e = a \left( \cos{\alpha} - e\right)\\ q &= b \sin{\alpha} \end{align*} \end{equation*}

e
0.6

Equation (21) represents the parametric form of an ellipse centred at its primary focus.

❓ Cartesian coordinates of an ellipse

The Perifocal Coordinate System

This frame of reference is known as the perifocal coordinate system; the horizontal and vertical axes are called P and Q, and their directions are aligned with the major and minor axes, respectively. The third axis, W=P \times Q, would be poking out of the screen.

❓ Right-hand rule

This special frame of reference was chosen by Kepler, as having the ellipse aligned along its major axis and centred in its main focus simplifies a lot of the calculations.

❓ How is the perifocal coordinate system defined for circular orbits?

The distance of a satellite from its central body changes over time. Its closest point is called the periapsis (plural: periapses); the furthest is the apoapsis (plural: apoapses). Specialised terms also exist, depending on the context; for instance, the closest and furthest points to the Sun are called the perihelion and the aphelion, respectively.

Orbiting aroundClosest pointFarthest point
GenericPeriapsisApoapsis
SunPerihelionAphelion
EarthPerigeeApogee
StarPeriastronApoastron

📃 List of specialised terms for periapsis and apoapsis

Both apses lie on opposite sides of the major axis. Within the perifocal reference frame, the P axis is sometimes defined as the direction from the primary focus to the periapsis. As a convention, that is also the axis from which angles are measured.

Angular positions

Historically, angular measures of a satellite’s position along its orbit are called anomalies. We have briefly mentioned one of them in the ¶ Angular position section, but it is now the time to see all of them in detail.

They are the true anomaly (\nu), the mean anomaly (M), and the eccentric anomaly (E). Out of the three, only \nu is a quantity that can be measured directly. The other two angles are geometrical constructions that do not represent anything physical, but play an important role in the equations that govern the orbital mechanics.

True anomaly (\nu)

The true anomaly (\nu) is represented by the Greek letter Nu, although sometimes \theta is also used. It measures the position of the satellite along its orbit, as the angle it makes with the direction of periapsis (the P axis in the perifocal reference frame), measured from the primary focus.

The true anomaly is the most natural of the three Keplerian anomalies, as it is a direct measure of the actual position of the satellite.

❓ Why is the angle of the satellite called the true anomaly?

Unfortunately, the true anomaly changes non-linearly with time. The velocity of a satellite, in fact, changes depending on its position along the orbit: it is the fastest at the periapsis, and the slowest at the apoapsis.

 

In general, there are no closed-form equations that link the true anomaly to the time, making it difficult to convert between these two values. This is the reason why two other angular measures have been introduced.

Mean anomaly (M)

The mean anomaly (M) does not describe something directly observable. It measures the angular position that a satellite would have if its orbit were perfectly circular, while retaining the same orbital period P and semi-major axis a. It is measured from the centre of the ellipse (rather than the primary focus, like the true anomaly).

The yellow orbit that circumscribes the ellipse is called the auxiliary circle, and represents the “circularised” version of the original orbit.

The mean anomaly represents the “best case” for astronomers: the situation which makes the calculations as easy as possible. In a circular orbit, in fact, a satellite moves at a constant speed along its path.

This means that, in opposition to the true anomaly, the mean anomaly represents the fraction of the orbit that has elapsed since the last periapsis passage (the time from periapsis, also known as the time since periapsis passage t_p):

(25)   \begin{equation*}  M=\frac{2\pi}{T}t_p \end{equation*}

🟰 Full derivation (M)

Unfortunately, there is no direct way to convert between the true anomaly and the mean anomaly.

Eccentric anomaly (E)

Like the mean anomaly, the eccentric anomaly (E) is another geometrical construction without a physical counterpart.

However, it serves as a “bridge” between the true anomaly (directly measured, but mathematically intractable) and mean anomaly (mathematically convenient, but idealised).

As seen before when we encountered the parametric equation of an ellipse centred at its primary focus (21), the eccentric anomaly is the angle of the satellite, if we could magically “stretch” its elliptical orbit into a circle. Although similar, this is conceptually very different from the mean anomaly (which value is not directly calculated from the position of the satellite).

e
0.6

❓ Difference between the mean and the eccentric anomaly

In the previous section (¶ Stretching circles), we worked backwards: starting from a circular orbit, and “squishing” its vertical axis down to turn it into an ellipse. Here, we see the eccentric anomaly arising through the reverse process: we start with an elliptical orbit, and we “stretch” its vertical axis up to turn it into a circle. The angular position that the satellite would have on its auxiliary circle is the eccentric anomaly E.

The eccentric anomaly is strongly related to the original orbit through a linear transformation. Likewise, it is connected to the mean anomaly as they are both defined on the same auxiliary circle. Thanks to these two facts, the eccentric anomaly sits somewhere “in between” the true anomaly and the mean anomaly, allowing conversions between them.

Relationship between the anomalies

You can interact with the diagram below to explore the relationship between the true anomaly, the eccentric anomaly, and the mean anomaly.

e
0.6
 

Eν

The true anomaly (\nu) and the eccentric anomaly (E) are related by the following equations:

(27)   \begin{equation*}  \tan{\frac{\nu}{2}} = \sqrt{\frac{1+e}{1-e}} \tan{\frac{E}{2}} \end{equation*}

(28)   \begin{equation*}  \tan{\frac{E}{2}} = \sqrt{\frac{1-e}{1+e}} \tan{\frac{\nu}{2}} \end{equation*}

🟰 Full derivation (E→ν)

❓ The direct relationship between ν and E

ME

The mean anomaly (M) and the eccentric anomaly (E) are related by the Kepler’s equation:

(42)   \begin{equation*}  M = E - e \sin{E} \end{equation*}

🟰 Full derivation (ME)

Kepler’s equation is transcendental: it cannot be solved for E algebraically. The section ¶ Solving Kepler’s equation will explore numerical methods to approximate a solution.

Orbital orientation

Keplerian orbits are “flat”: the movement of a satellite is constrained to a 2D plane, called the orbital plane. However, orbits exist in a 3D space, and do not necessarily have to move on the same orbital plane of their central body. Even within the solar system, each planet orbits the Sun with a slightly different inclination. The orbital plane of Mercury, for instance, is tilted 7.01° compared to Earth’s.

❓How are orbital planes measured in the solar system?

🕹️ You can interact with the 3D diagram below to see a satellite which orbital plane (PQ) intersects the orbital plane of its central body (XY) at an angle.

When the orbital plane is tilted, the satellite will pass through the reference plane twice. The point where it “pierces” it from below is called the ascending node (☊); the one from above to below is the descending node (☋). The line between them is called the line of nodes (☋☊), and it lies on the intersection of the two orbital planes.

Euler angles

There are many ways to define the orientation of an object in 3D space, such as quaternions and rotation matrices; Keplerian orbits typically use Euler angles. They are three numbers which characterise the orientation of the orbital plane, with respect to a default reference frame (sometimes called inertial frame). That could either be the orbital plane of the central body, or any other conventionally agreed plane.

❓ What are Euler angles?

In a nutshell, three angles measure how much the XYZ axes of the reference frame need to rotate to align with the PQW axes of the perifocal frame (described in the section ¶ Perifocal Coordinate System). In line with the naming convention used by Kepler, they are the:

NameSymbolDescriptionRotation Axis
Longitude of the ascending node\OmegaRotation of the line of nodes (☋☊) on the reference frame (XY)Z
InclinationiTilt of the orbital plane (PQ) from the reference plane (XY), around the line of nodes (☋☊)Line of nodes (☋☊)
Argument of periapsis\omegaRotation of the orbit inside its orbital plane (PQ)W

Let’s see them one by one, before analysing how to use them mathematically.

Argument of periapsis (\omega)

The argument of periapsis is the only angle of the three that can be fully explained in the perifocal coordinate system. Within the orbital plane (PW), it corresponds to a rotation around the primary focus:

\omega
15
°

The direction of periapsis refers to the direction to the closest point on the orbit, which corresponds to the P axis. The angle \omega is called the argument of periapsis because its meaning is to offset that axis.

When we extend into three dimensions, we see that \omega rotates the orbit around the W axis of the perifocal frame:

\omega
45
°

The argument of periapsis is typically defined as the orientation of the orbital plane, measured from the ascending node (☊) to the direction of periapsis (P axis).

Inclination (i)

The inclination represents the vertical tilt of the orbital plane (PW) with the reference plane (XY), measured at the ascending node (☊).

i
45
°

The red line on the XY plane represents the line of nodes, which is where the two orbital planes intersect.

The inclination is measured in the range \left[0^{\circ}, 180^{\circ}\right]. When the inclination is between 90^{\circ} and 180^{\circ}, the orbit is retrograde and the satellite is revolving in the opposite direction.

📃 List of orbital inclinations

Longitude of the ascending node (\Omega)

The longitude of the ascending node is also called the right ascension of the ascending node (RAAN), and represents the orientation of the line of nodes (☋☊) on the reference plane XY, measured from the reference direction X.

\Omega
45
°

It corresponds to a rotation around the Z axis, and is typically defined as the angle from the ascending node (☊) and the reference frame direction (X).

Conversions

\omega, i, and \Omega represent the rotation of the perifocal frame PQW, measured from the reference frame XYZ. When \omega=i=\Omega=0, the orbital plane is perfectly aligned with the reference plane, and the PQW and XYZ axes overlap.

Geometrically, we can visualise the transformation from the PQW frame to the XYZ frame as the sequence of rotations necessary to align the XYZ axes to the actual orientation of the PQW axes:

\omega
45
°
i
45
°
\Omega
45
°

You can play with multiple elliptical orbits using the interactive tool at Orbital Mechanics.

PQWXYZ

A point \tiny \begin{bmatrix} p \\ q \\ w \end{bmatrix} in the perifocal coordinate system (defined by the PQW axes) is expressed in the reference coordinate system (defined by the XYZ axes) through the following sequence of rotations:

OrderAxis of rotationRotationEffect
1stZ (or W)\omegaRotates the orbit inside its orbital plane (PQ)
2ndXiTilts the orbital plane (PQ) from the reference plane (XY), around the line of nodes (☋☊) (which at this stage is still aligned with the X axis)
3rdZ\OmegaRotates the line of nodes (☋☊) on the reference frame (XY)

This is called an extrinsic Euler rotation of the type Z-X-Z, since the three rotations are happening first around the Z axis, then around the X axis, and lastly around the Z axis again.

❓ Extrinsic vs Intrinsic rotations

❓ Rotation sequences in matrix notation

This transformation is expressed with the following rotation matrix:

(51)   \begin{equation*}  R = R_Z\left(\Omega\right) \cdot R_X\left(i\right) \cdot R_Z\left(\omega\right) \end{equation*}

which expands into:

(52)   \begin{equation*}  \footnotesize R = \underset{R_Z\left(\Omega\right)} {\underbrace{   \begin{bmatrix}     \cos{\Omega} & -\sin{\Omega} & 0 \\     \sin{\Omega} & \phantom{+}\cos{\Omega} & 0 \\     0 & 0 & 1 \\   \end{bmatrix} }} \cdot \underset{R_X\left(i\right)} {\underbrace{   \begin{bmatrix}     1 & 0 & 0 \\     0 & \cos{i} & -\sin{i} \\     0 & \sin{i} & \phantom{+}\cos{i} \\   \end{bmatrix} }} \cdot \underset{R_Z\left(\omega\right)} {\underbrace{   \begin{bmatrix}     \cos{\omega} & -\sin{\omega} & 0 \\     \sin{\omega} & \phantom{+}\cos{\omega} & 0 \\     0 & 0 & 1 \\   \end{bmatrix} }} \end{equation*}

❓ Understanding the order of rotation matrices

XYZPQW

Converting a point \tiny \begin{bmatrix} x \\ y \\ z \end{bmatrix} from the reference coordinate system (defined by the XYZ axes) in the perifocal coordinate system (defined by the PQW axes) requires a transformation opposite to (54). This means “undoing” all rotations, in reversed order:

(54)   \begin{equation*}  R^{-1} = R_Z\left(-\omega\right) \cdot R_X\left(-i\right) \cdot R_Z\left(-\Omega\right) \end{equation*}

(55)   \begin{equation*}  \tiny R^{-1} = \underset{R_Z\left(-\omega\right)} {\underbrace{   \begin{bmatrix}     \cos{\left(-\omega\right)} & -\sin{\left(-\omega\right)} & 0 \\     \sin{\left(-\omega\right)} & \phantom{+}\cos{\left(-\omega\right)} & 0 \\     0 & 0 & 1 \\   \end{bmatrix} }} \cdot \underset{R_X\left(-i\right)} {\underbrace{   \begin{bmatrix}     1 & 0 & 0 \\     0 & \cos{\left(-i\right)} & -\sin{\left(-i\right)} \\     0 & \sin{\left(-i\right)} & \phantom{+}\cos{\left(-i\right)} \\   \end{bmatrix} }} \cdot \underset{R_Z\left(-\Omega\right)} {\underbrace{   \begin{bmatrix}     \cos{\left(-\Omega\right)} & -\sin{\left(-\Omega\right)} & 0 \\     \sin{\left(-\Omega\right)} & \phantom{+}\cos{\left(-\Omega\right)} & 0 \\     0 & 0 & 1 \\   \end{bmatrix} }} \end{equation*}

You can read more on Orbital elements.

❓ Inverting rotations

❓ The signs in your code are inverted!

Keplerian Orbital Elements

The orbital elements are a set of parameters needed to fully define a Keplerian orbit, and to make predictions. The classical Keplerian orbital elements are:

  • Orbital shape:
    • Eccentricity (e);
    • Semi-major axis (a).
  • Orbital inclination:
    • Inclination (i);
    • Longitude of the ascending node (\Omega);
    • Argument of periapsis (\omega).
  • Satellite position:
    • Time since periapsis (t_p).

The first five parameters fully define the shape of the ellipse; an extra parameter (sometimes two) is needed to predict the position of the satellite.

Orbital elements VS Orbital state vectors

Other sets of parameters can be used, depending on what type of orbital measurements are available. This is because many parameters can be derived from each other.

📃 Orbital shape

📃 Orientation of the orbital plane

📃 Orbital motion

📃 Satellite position

A comprehensive list can be found at Orbital element: Required parameters.

📃 The orbital elements for the planets in the solar system

Part 3: Orbital prediction

In ¶ Part 2: Understanding Keplerian Orbits, we explored to Mathematics of Keplerian orbits, and the measurements needed to fully characterise them (the ¶ Keplerian orbital elements). We now have everything we need to answer the original question: how to predict the position of a satellite along its orbit at a given time?

Any point on an elliptical path can be uniquely identified using an angular metric, such as the eccentric anomaly (E) or the true anomaly (\nu). Their relationship with time is non-linear, making it difficult to calculate it directly. This problem is solved by calculating the mean anomaly (M) first, which does grow linearly with time. We can then convert it to the corresponding eccentric anomaly by solving Kepler’s equation. The angle found is then used to locate the position of the satellite in the perifocal reference frame PQ:

  • 1️⃣ t \rightarrow M: Calculate the mean anomaly from the current time (via a linear relationship);
  • 2️⃣ M \rightarrow E: Calculate the eccentric anomaly from mean anomaly (via Kepler’s equation);
  • 3️⃣ E \rightarrow {\tiny \begin{bmatrix} p \\ q \end{bmatrix}}: Calculate the position of the body in the perifocal reference frame (via the parametric form of an ellipse);
  • 4️⃣ {\tiny \begin{bmatrix} p \\ q \\0 \end{bmatrix}} \rightarrow {\tiny \begin{bmatrix} x \\ y \\ z \end{bmatrix}}: Calculate the position in the reference frame (via the orbital inclination elements).

(58)   \begin{equation*}  t\xrightarrow[]{\text{Mean motion}} M\xrightarrow[]{\text{Kepler's eq.}} E\xrightarrow[]{\text{Parametric form}} {\footnotesize \begin{bmatrix}p\\q\end{bmatrix}}\xrightarrow[]{\text{Rotation}} {\footnotesize \begin{bmatrix}x\\y\\z\end{bmatrix}} \end{equation*}

Let’s see them all one by one.

❓ How to get the true anomaly?

🟰 Full derivation (E → ν)

❓ What is atan2?

❓ How to get the position from the true anomaly?

1️⃣Calculate M from t

The mean anomaly grows linearly with time. The mean motion (n) is the angular speed of the mean anomaly, and measures its change per unit of time:

(72)   \begin{equation*}  n = \sqrt{\frac{\mu}{a^3}} \end{equation*}

where \mu = G m_1 is the gravitational parameter of the central body.

The mean anomaly can then be found using the following linear relationship:

(73)   \begin{equation*}  M = M_0 + n \left(t-\tau\right) \end{equation*}

where:

  • M_0 is the value of the mean anomaly measured at epoch (t_0);
  • t is the current time;
  • \tau is the time of periapsis passage, which is the time when the satellite was at periapsis last; this is different from the time since periapsis (t_p=t-\tau), which measures how much time has passed since the last periapsis passage.

❓ Time since periapsis

2️⃣ Calculate E from M

The section ¶ Relationship between the anomalies explained how there is no analytical solution to calculate the eccentric anomaly (E) from the mean anomaly (E). This is because the equation that connected these two quantities—Kepler’s equation (42)—is transcendental:

(75)   \begin{equation*} % M=E - e \sin{E} \end{equation*}

The Kepler’s equation can be solved numerically to find an approximate answer. Newton’s method is the first choice due to its simplicity, and it provides progressively more accurate estimates with each iteration:

(76)   \begin{equation*}  \begin{align*} E_0 &= M \\ E_{i+1} &= E_i - \frac{f\left({E_i}\right)}{f'\left({E_i}\right)} \end{align*} \end{equation*}

where:

(77)   \begin{equation*}  \begin{align*} f\left(E\right) &= E - e \sin{E} - M \\ f'\left(E\right) &= 1 - e \cos{E} \end{align*} \end{equation*}

The method usually converges very rapidly, generally taking only two or three iterations to get very good approximations.

💾 Full code

❓ How does Newton’s method work?

If you want to learn more about Kepler’s equations, I highly recommend this Welch Labs’ video:

3️⃣ Calculate \begin{bmatrix} p \\ q \end{bmatrix} from E

The position of a point on an ellipse can be found using the parametric form of the ellipse (21) that we encountered in ¶ Deriving Keplerian orbits:

(79)   \begin{equation*} % \begin{align*} p &= a \left( \cos{E} - e\right)\\ q &= b \sin{E} \end{align*} \end{equation*}

where b = a \sqrt{1-e^2}.

The point \tiny \begin{bmatrix} p \\ q \end{bmatrix} represents the position of the satellite expressed in the perifocal coordinate system, where the central body is at \tiny\begin{bmatrix} 0 \\ 0 \end{bmatrix} and the horizontal and vertical axes (P and Q) are aligned with the semi-axes.

4️⃣ Calculate \begin{bmatrix} x \\ y \\ z \end{bmatrix} from \begin{bmatrix} p \\ q \end{bmatrix}

A further transformation is necessary if the point \tiny \begin{bmatrix} p \\ q \end{bmatrix} has to be expressed in the reference coordinate system. This means taking into account the orbital orientation expressed by the inclination (i), the longitude of the ascending node (\Omega), and the argument of periapsis (\omega).

The ¶ Conversions section defined the orbital orientation with an extrinsic Z-X-Z Euler rotation, summarised by (54):

    \begin{equation*} \label{R_pqw2xyz_2} %bis R = R_Z\left(\Omega\right) \cdot R_X\left(i\right) \cdot R_Z\left(\omega\right) \end{equation*}

The conversion between \tiny \begin{bmatrix} p \\ q \end{bmatrix} and \tiny\begin{bmatrix} x \\ y \\ z \end{bmatrix} is done using (53):

    \begin{equation*} \label{R_pqw2xyz_full_2} %bis \begin{bmatrix} x \\ y \\ z \end{bmatrix} = R \cdot \begin{bmatrix} p \\ q \\ 0 \end{bmatrix} \end{equation*}

❓ Show me the full equation

The point \tiny \begin{bmatrix} x \\ y \\ z \end{bmatrix} is a new representation of the point \tiny \begin{bmatrix} p \\ q \end{bmatrix}, expressed in a different coordinate system. The origin (\tiny \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix}) is still the position of the central body, but the new axes share the same orientation as the perifocal coordinate system of the central body.

If you need to find the position with respect to the centre of the planetary system (i.e.: the Sun), an extra step is necessary to add the position of the central body in its own perifocal coordinate system to \tiny \begin{bmatrix} x \\ y \\ z \end{bmatrix}.

❓ Hierarchical planetary systems

Part 4: Unbound trajectories

¶ Part 2 and ¶ Part 3 of this article focused on bound Keplerian orbits, which trace circular and elliptical orbits. This section focuses on unbound Keplerian trajectories: parabolas and hyperbolas.

The focus will be predominantly on hyperbolas: some simulators do not include the parabolic case, which is treated as a hyperbola with an eccentricity very close to 1.

❓ The Universal Variable Formulation

Hyperbolic trajectories

The eccentricity e of an ellipse measures how far the foci are from the centre, as a fraction of the semi-major axis. When e=0, both foci are at the centre; as e\rightarrow 1, the foci get closer and closer to the edge of the ellipse. When e>1, the foci would effectively be “outside” of the ellipse, “breaking” it (so to speak).

The curvature of the elliptical path suddenly changes, and instead of looping onto itself to form a closed orbit, it splits into two separate branches.

The interactive diagram below shows what happens to a conic section when its semi-major axis a is fixed, but its eccentricity e is allowed to change:

e
0.6

In the diagram above, you can also see a box that represents the size of the major and minor axes of the hyperbola, as well as its asymptotes, showing the trajectories at infinity. You can read more about the geometrical properties of hyperbolas here.

❓ What about parabolas?

The hyperbolic anomaly

The eccentric anomaly of an ellipse is the angle to the vertical projection of the satellite on the auxiliary circle. The equivalent construction for a hyperbola is the auxiliary equilateral hyperbola whose eccentricity e=\sqrt{2}.

At this point, one might be tempted to make a parallel with the eccentric anomaly, thinking of its hyperbolic equivalent as the angle to the vertical projection of the satellite on the auxiliary equilateral hyperbola. That would be incorrect: the hyperbolic anomaly H (sometimes F) is not directly related to any angle, but to the area of the hyperbolic sector:

H
1

(82)   \begin{equation*}  H=\frac{2 A}{a^2} \end{equation*}

where A is the (signed) area of the hyperbolic sector between the major axis and a line that goes from the satellite position projected, bounded by the auxiliary equilateral hyperbola. You can read more about this in Hyperbolic trajectories.

The mean anomaly of a hyperbola still advanced uniformly with time. Similarly to the hyperbolic anomaly, it does not represent a physical angle, but the (signed) area of a hyperbolic sector of the auxiliary equilateral hyperbola.

Neither anomalies are bound to the range \left[0, 360^{\circ}).

Equations

An ellipse is defined as the set of points whose sum of distances from the fixed foci is constant. A hyperbola follows the same property, but what remains constant is not the sum of distances, but their difference.

❓ Cartesian coordinates of a hyperbola

The immediate consequence is that many of the hyperbolic equations are equivalent to the elliptical ones, but with their sign flipped:

PropertyEllipseHyperbola
Eccentricity0 \le e < 1e > 1
Semi-major axisa > 0a < 0
Semi-minor axisb=\sqrt{1-e^2}b=\sqrt{e^2-1}
Parametric formx = a \left(\cos{E} -e\right)
y = b \sin{E}
x = +a \left(\cosh{H} -e\right)
y &= -b \sinh{H}
Cartesian coordinates\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1\frac{x^2}{a^2} - \frac{y^2}{b^2} = 1
Mean anomalyM=E-e\sin{E}M=e\sinh{H}-H
Mean motionn=\sqrt{\frac{\mu}{a^3}}n=\sqrt{\frac{\mu}{\left(-a\right)^3}}

For instance: the semi-minor axis is \sqrt{1-e^2} for an ellipse, and \sqrt{e^2-1} for a hyperbola (which is just a different way of writing \sqrt{-1+e^2}).

This also explains why the hyperbolic equations can sometimes be found in different forms, such as p being either p = +a \left(\cosh{H} -e \right) or p = -a \left(e- \cosh{H}\right).

❓ Why does the hyperbola use hyperbolic functions?

❓ The direct relationship between ν and H

Parabolic trajectories

Throughout the article, it was said that the characteristic of parabolic trajectories is that e=1. While that is technically correct, it is not enough to turn an elliptical orbit into a parabolic trajectory. If we take an ellipse and change its eccentricity (e) to 1 while keeping its semi-major axis (a) fixed and finite, the shape will not open up into a parabola, but degenerate to a line segment instead. This happens because as e approaches 1, the semi-minor axis (b=a \sqrt(1-e^2)) approaches 0.

A parabola can be thought of as the edge case of an ellipse, when its semi-major axis goes to infinity (a \rightarrow \infty) while its eccentricity goes to 1 (e \rightarrow 1).

🟰 Full derivation

It is not uncommon for Keplerian simulators to ignore the parabolic case, writing code for only two cases: bound orbits (i.e. circular and elliptical) and unbound trajectories (i.e. hyperbolic).

The parabolic anomaly

Like ellipses and hyperbolas, parabolas have their own anomaly, known as the parabolic anomaly (D, also called Barker’s variable). D is neither an angle (like E) nor an area (like H), but is a function of the true anomaly \nu defined as:

(99)   \begin{equation*}  D= \tan{\frac{\nu}{2}} \end{equation*}

The parabolic time equation (also known as Barker’s equation) links the time since periapsis (t_p=t-\tau) to the parabolic anomaly (D):

(100)   \begin{equation*}  t_p = \frac{1}{2} \sqrt{\frac{p^3}{\mu}} \left(D + \frac{D^3}{3}\right) \end{equation*}

where:

  • p is the semi-latus rectum;
  • \mu=G m_1 is the standard gravitational parameter.

When trying to find the position of a satellite travelling along a parabolic trajectory, we can use Barker’s equation without the need to calculate the mean anomaly:

(101)   \begin{equation*}  t \xrightarrow[]{\text{Barker's eq.}} D \xrightarrow[]{\text{Parametric form}} {\footnotesize \begin{bmatrix}p\\q\end{bmatrix}}\xrightarrow[]{\text{Rotation}} {\footnotesize \begin{bmatrix}x\\y\\z\end{bmatrix}} \end{equation*}

However, the Barker’s equation replaces Kepler’s equation for parabolas, and can be solved analytically:

(102)   \begin{equation*}  M = D + \frac{D^3}{3} = \sqrt{\frac{\mu}{2 {r_p}^3}} t_p \end{equation*}

where r_p is the periapsis distance (r_p= 2 p for parabolas).

Equations

Because a=\infty, many of the equations previously derived are no longer valid. The semi-minor axis and the mean motion are not defined for parabolas.

For completeness, you can refer to the following table:

PropertyParabolaHyperbola
Eccentricitye = 1e > 1
Semi-major axisa = \inftya < 0
Semi-minor axisundefinedb=\sqrt{e^2-1}
Parametric formx = \frac{p}{2}\left(1-D^2\right)
y=p D
x = +a \left(\cosh{H} -e\right)
y &= -b \sinh{H}
Cartesian coordinatesy^2=2 p x\frac{x^2}{a^2} - \frac{y^2}{b^2} = 1
Mean anomalyM=D+\frac{D^3}{3}
(Barker’s equation)
M=e\sinh{H}-H
Mean motionundefinedn=\sqrt{\frac{\mu}{\left(-a\right)^3}}

Parabolic trajectories are fully determined only by their periapsis distance from the central body.

Conclusion

Summary

This article explored the fascinating topic of orbital mechanics for the two-body problem. In this scenario, celestial bodies follow trajectories which are shaped like conic sections: ellipses, parabolas, and hyperbolas.

We have seen the mathematics that governs each trajectory, and defined a simple algorithm to calculate the position of a satellite using its Keplerian orbital elements:

(103)   \begin{equation*}  % % \resizebox{0.1\textwidth}{!}{ \tiny  \begin{array}{rccccccccc} \text{Elliptical:} & t & \xrightarrow[]{\text{Mean motion}} & M & \xrightarrow[]{\text{Kepler's eq.}} & E & \xrightarrow[]{\text{Parametric form}} & {\begin{bmatrix}p\\q\end{bmatrix}} & \xrightarrow[]{\text{Rotation}} & {\begin{bmatrix}x\\y\\z\end{bmatrix}} \\ \text{Hyperbolic:} & t & \xrightarrow[]{\text{Mean motion}} & M & \xrightarrow[]{\text{Kepler's eq.}} & H & \xrightarrow[]{\text{Parametric form}} & {\begin{bmatrix}p\\q\end{bmatrix}} & \xrightarrow[]{\text{Rotation}} & {\begin{bmatrix}x\\y\\z\end{bmatrix}} \\ \text{Parabolic:} & t & \multicolumn{3}{c}{ \xrightarrow[]{\hspace{3.5em}\text{Barker's eq.}\hspace{3.5em}} } & D & \xrightarrow[]{\text{Parametric form}} & {\begin{bmatrix}p\\q\end{bmatrix}} & \xrightarrow[]{\text{Rotation}} & {\begin{bmatrix}x\\y\\z\end{bmatrix}} \\ \end{array} % } \end{equation*}

You can find a summary of all the main equations below:

📃 All equations

What’s next?

A future article will explore the mathematics of orbital manoeuvres, which allow a spacecraft to change its orbit through controller burns.

And another instalment will show how to write a full Keplerian orbital simulator in Unity/C#.

Further readings

You can learn more about orbital mechanics here:

Credits: cover background image.

Comments

One response to “Orbital Mechanics”

  1. […] разбор орбитальной механики: от реализации симуляции гравитации до математики, […]

Leave a Reply

Your email address will not be published. Required fields are marked *

">