Post · 15 min read· pp. 133–141

Classical Orbital Elements and the State Vector

As we saw in the last section, we can replace the six elements in the state vector with six orbital elements which describe the orbit. If the position and velocity vectors are known, we need to be able to convert them to the classical orbital elements. Likewise, if we have six independent orbital elements, we might want to convert them into a state vector.

State Vector → Orbital Elements

Let’s assume that we are given the state vector, composed of \vectorr\vector{r} and \vectorv\vector{v} at some time t0t_0. We would like to determine the six classical orbital elements:

  1. hh
  2. ee
  3. ii
  4. Ω\Omega
  5. ω\omega
  6. ν\nu

As we discussed previously, this set of six elements is not unique; for instance, the orbital angular momentum hh can be replaced by the semi-major axis distance, aa. Nonetheless, this set of six is a convenient set to calculate and other elements can be determined from this set.

Step 1—Position and Velocity Magnitudes

The first step in the conversion is to calculate rr, vv, vrv_r, and v⊥v_{\perp}. Recall that the radial velocity is the projection of the velocity vector onto the unit radial vector:

vr=\vectorv⋅\vectorrrv_r = \vector{v} \cdot \frac{\vector{r}}{r}

(182)

and we can subsequently find the azimuthal velocity by the Pythagorean theorem:

v⊥=v2−vr2v_{\perp} = \sqrt{v^2 - v_r^2}

(183)

Python

Matlab

python
import numpy as np

r_vec = np.array((1_000, 5_000, 7_000))  # km
v_vec = np.array((3.0, 4.0, 5.0))  # km/s
mu = 3.986e5  # km^3/s^2

r = np.linalg.norm(r_vec)
v = np.linalg.norm(v_vec)
v_r = np.dot(r_vec / r, v_vec)
v_p = np.sqrt(v**2 - v_r**2)

diagram

orbital_elements_and_the_state_vector.m

matlab
r_vec = [1000, 5000, 7000]; % km
v_vec = [3.0, 4.0, 5.0]; % km/s
mu = 3.986E5; % km^3/s^2

r = norm(r_vec);
v = norm(v_vec);
v_r = dot(r_vec/r, v_vec);
v_p = sqrt(v^2 - v_r^2);

For this example, we find r=r = 8660.254 km, v=v = 7.071 km/s, vr=v_r = 6.697 km/s, and v⊥=v_{\perp} = 2.269 km/s.

Step 2—Orbital Angular Momentum

Next, we need to calculate the orbital angular momentum. By definition, \vectorh=\vectorr\cross\vectorv\vector{h} = \vector{r}\cross\vector{v}. We also need the magnitude of the angular momentum.

Python

Matlab

python
h_vec = np.cross(r_vec, v_vec)
h = np.linalg.norm(h_vec)

diagram

orbital_elements_and_the_state_vector.m

matlab
h_vec = cross(r_vec, v_vec);
h = norm(h_vec);

We find \vectorh=\vector{h} = -3000 \uvecI\uvec{I} + 16000 \uvecJ\uvec{J} - 11000 \uvecK\uvec{K} km2/s and h=h = 19646.883 km2/s. Notice that the ZZ component of the angular momentum is negative. This means the momentum vector is pointing down and the orbit is retrograde. The magnitude of the orbital angular momentum is the first orbital element.

Step 3—Inclination

Once the angular momentum is calculated, we can calculate the inclination, ii. Let’s form a right triangle with one leg as the ZZ component of the angular momentum and the hypotenuse as the magnitude of the angular momentum. Then the inclination is the angle adjacent to hZh_Z and can be found by the inverse cosine, as shown in Eq. 184.

i=cos⁡−1(hZh)i = \cos^{-1}\left(\frac{h_Z}{h}\right)

(184)

Since the inclination is restricted to lie between 0° and 180°, we do not need to worry about the quadrant ambiguity inherent in the inverse cosine function.

Python

Matlab

python
i = np.arccos(h_vec[2] / h)

diagram

orbital_elements_and_the_state_vector.m

matlab
i = acos(h_vec(3) / h);

The inclination of this orbit is i=i = 124.05°. We know for retrograde orbits, the inclination must be between 90° and 180°, which is the case here. The inclination is the second orbital element.

Step 4—Right Ascension of the Ascending Node

Next, we will calculate the right ascension of the ascending node. The ascending node is the point on the line of nodes where the spacecraft ascends above the reference plane. Since the line of nodes is defined by the intersection of the orbital plane and the reference plane, it must lie in both planes.

Therefore, the node line is perpendicular to the normal vectors of both the reference plane and the orbital plane. We can find the perpendicular vector by taking the cross product of a vector normal to the reference plane and a vector normal to the orbital plane. For convenience, we choose the \uvecK\uvec{K} vector and the \vectorh\vector{h} vector, as shown in Eq. 185.

\vectorN=\uvecK\cross\vectorh\vector{N} = \uvec{K}\cross\vector{h}

(185)

Then, similar to the inclination, we form a right triangle where the XX component of \vectorN\vector{N} is one leg and the magnitude of \vectorN\vector{N} is the hypotenuse. The right ascension of the ascending node is the angle adjacent to NXN_X so it can be found by the inverse cosine, as shown in Eq. 186.

Ω=cos⁡−1(NXN)\Omega = \cos^{-1}\left(\frac{N_X}{N}\right)

(186)

However, unlike the inclination, Ω\Omega can vary from 0° to 360°, so we need to determine the appropriate quadrant for the resulting angle. We can do this by comparing the sign of the YY component of \vectorN\vector{N}.

If NY≥0N_Y \geq 0, then \vectorN\vector{N} must be pointing to the first or second quadrant and 0° ≤ Ω\Omega ≤ 180°. If NY<0N_Y < 0, then \vectorN\vector{N} must be pointing to the third or fourth quadrant, so 180° < Ω\Omega < 360°. We can express this fully with the conditions in Eq. 187.

Ω={cos⁡−1(NXN)NY≥02π−cos⁡−1(NXN)NY<0\Omega = \begin{cases} \cos^{-1}\left(\frac{N_X}{N}\right) & N_Y \geq 0 \\ 2\pi - \cos^{-1}\left(\frac{N_X}{N}\right) & N_Y < 0 \end{cases}

(187)

Python

Matlab

python
K = np.array((0, 0, 1))
N_vec = np.cross(K, h_vec)
N = np.linalg.norm(N_vec)
Omega = 2 * np.pi - np.arccos(N_vec[0] / N)

diagram

orbital_elements_and_the_state_vector.m

matlab
K = [0, 0, 1];
N_vec = cross(K, h_vec);
N = norm(N_vec);
Omega = 2 * pi - acos(N_vec(1)/N);

For this problem, we find NY=N_Y = -3000, so the right ascension of the ascending node is in the third or fourth quadrant. Then, we find Ω=\Omega = 190.62°. The right ascension of the ascending node is the third orbital element.

Step 5—Eccentricity

The fourth orbital element is the eccentricity. Way back in Eq. 122, we found the eccentricity vector as the constant of integration of the equation of motion. Repeating the equation here:

\vectore=\vectorr˙\cross\vectorhμ−\vectorrr\vector{e} = \frac{\dot{\vector{r}}\cross\vector{h}}{\mu} - \frac{\vector{r}}{r}

If you’re using a computer to do calculations, this form is the simplest to use. However, we can replace the cross product and simplify Eq. 122 somewhat.

\vectore=1μ[(v2−μr)\vectorr−rvr\vectorv]\vector{e} = \frac{1}{\mu}\left[\left(v^2 - \frac{\mu}{r}\right)\vector{r} - r v_r \vector{v}\right]

(188)

Eq. 188 is useful if you’re doing calculations out by hand, since you don’t have to do any cross products, only scalar multiplications of the vectors.

The magnitude of the eccentricity can be found in the usual method programmatically, or with a form simplified from Eq. 188, as shown in Eq. 189.

e=1+h2μ2(v2−2μr)e = \sqrt{1 + \frac{h^2}{\mu^2}\left(v^2 - \frac{2\mu}{r}\right)}

(189)

Again, Eq. 189 is useful for hand calculations.

Python

Matlab

python
e_vec = np.cross(v_vec, h_vec) / mu - r_vec / r
e = np.linalg.norm(e_vec)

diagram

orbital_elements_and_the_state_vector.m

matlab
K = [0, 0, 1];
N_vec = cross(K, h_vec);
N = norm(N_vec);
Omega = 2 * pi - acos(N_vec(1)/N);

% [section-5]
e_vec = cross(v_vec, h_vec) / mu - r_vec / r;
e = norm(e_vec);

The eccentricity of this orbit is e=e = 0.948, so the orbit is a very eccentric ellipse.

Step 6—Argument of Periapsis

The last two orbital elements are found using the algebraic definition of the dot product, Eq. 190.

\vectorA⋅\vectorB=ABcos⁡θ\vector{A}\cdot\vector{B} = A B \cos\theta

(190)

where \vectorA\vector{A} and \vectorB\vector{B} are arbitrary vectors, AA and BB are their magnitudes, and θ\theta is the angle between the vectors.

By definition, the eccentricity vector points towards periapsis. Moreover, the argument of periapsis is the angle from the ascending node to periapsis following around the orbit. In other words, the argument of periapsis is the angle between the eccentricity vector \vectore\vector{e} and the node line \vectorN\vector{N}. We can solve for ω\omega by using Eq. 190.

ω=cos⁡−1(\vectore⋅\vectorNeN)\omega = \cos^{-1}\left(\frac{\vector{e}\cdot\vector{N}}{e N}\right)

(191)

Like the right ascension of the ascending node, the argument of periapsis can vary from 0° to 360°. To determine the appropriate quadrant, we can inspect the sign of the ZZ component of \vectore\vector{e}.

If eZ≥0e_Z \geq 0, then \vectore\vector{e} points up and periapsis must be between the ascending node and descending node, so 0° ≤ ω\omega ≤ 180°. On the other hand, if eZ<0e_Z < 0, then periapsis must be between the descending and ascending nodes, and 180° < ω\omega < 360°. We can express this fully with the conditions in Eq. 192.

ω={cos⁡−1(\vectore⋅\vectorNeN))eZ≥02π−cos⁡−1(\vectore⋅\vectorNeN))eZ<0\omega = \begin{cases} \cos^{-1}\left(\frac{\vector{e}\cdot\vector{N}}{e N}\right)) & e_Z \geq 0 \\ 2\pi - \cos^{-1}\left(\frac{\vector{e}\cdot\vector{N}}{e N}\right)) & e_Z < 0 \end{cases}

(192)

Python

Matlab

python
omega = 2 * np.pi - np.arccos(np.dot(N_vec, e_vec) / (N * e))

diagram

orbital_elements_and_the_state_vector.m

matlab
omega = 2 * pi - acos(dot(N_vec, e_vec) / (N * e));

For this problem, we find eZ=e_Z = -0.6578, so the argument of periapsis is in the third or fourth quadrant. Then, we find ω=\omega = 303.09°. The argument of periapsis is the fifth orbital element.

Step 7—True Anomaly

The final orbital element is the true anomaly, ν\nu. The true anomaly is the angle from the apse line to the position vector. In other words, it is the angle between \vectore\vector{e} and \vectorr\vector{r}. We can solve for ν\nu by using Eq. 190.

ν=cos⁡−1(\vectore⋅\vectorrer)\nu = \cos^{-1}\left(\frac{\vector{e}\cdot\vector{r}}{e r}\right)

(193)

Like the right ascension of the ascending node, the true anomaly can vary from 0° to 360°. To determine the appropriate quadrant, we can inspect the sign of the radial component of the velocity, vrv_r.

If vr≥0v_r \geq 0, then \vectorr\vector{r} is increasing in length and the spacecraft must be flying away from periapsis, so 0° ≤ ν\nu < 180°. On the other hand, if vr<0v_r < 0, then \vectorr\vector{r} must be getting shorter and the spacecraft must be flying towards periapsis, such that 180° ≤ ν\nu < 360°. We can express this fully with the conditions in Eq. 194.

ν={cos⁡−1(\vectore⋅\vectorrer)vr≥02π−cos⁡−1(\vectore⋅\vectorrer)vr<0\nu = \begin{cases} \cos^{-1}\left(\frac{\vector{e}\cdot\vector{r}}{e r}\right) & v_r \geq 0 \\ 2\pi - \cos^{-1}\left(\frac{\vector{e}\cdot\vector{r}}{e r}\right) & v_r < 0 \end{cases}

(194)

Python

Matlab

python
nu = np.arccos(np.dot(r_vec / r, e_vec / e))

diagram

orbital_elements_and_the_state_vector.m

matlab
nu = acos(dot(e_vec, r_vec) / (e * r));

For this problem, we find vr=v_r = 6.6973 km/s, so the true anomaly is in the first or second quadrant. Then, we find ν=\nu = 159.61°. The true anomaly is the sixth and final orbital element.

Orbital Elements → State Vector

The algorithm to convert from the orbital elements back to the state vector is somewhat more involved, so we do not include the complete derivation here. There are two steps in this algorithm:

  1. Use the orbital elements ee, ν\nu, and hh to represent \vectorr\vector{r} and \vectorv\vector{v} in the perifocal frame
  2. Rotate the perifocal frame so that the axes align with the inertial axes using the orbital elements Ω\Omega, ω\omega, and ii.

The first step is rather simple, but the derivation of the second step requires a long digression on the topic of coordinate transformations. So, we’ll skip the derivation and get right to the point.

Step 1—Transform to Perifocal Frame

Remember that the perifocal frame is defined in the orbital plane with the unit vectors \uvecp\uvec{p}, \uvecq\uvec{q}, and \uvecw\uvec{w}, as shown in Fig. 42. The position and velocity components in the perifocal frame are given by Eq. 177 and Eq. 180, respectively.

Python

Matlab

python
r_w = h**2 / mu / (1 + e * np.cos(nu)) * np.array((np.cos(nu), np.sin(nu), 0))
v_w = mu / h * np.array((-np.sin(nu), e + np.cos(nu), 0))

diagram

orbital_elements_and_the_state_vector.m

matlab
r_w = h^2 / mu / (1 + e * cos(nu)) .* [cos(nu) sin(nu) 0];
v_w = mu / h .* [-sin(nu) e + cos(nu) 0];

For this example, we find \vectorrω=\vector{r}_{\omega} = -8117.7120 \uvecp\uvec{p} + 3017.0767 \uvecq\uvec{q} km and \vectorvω=\vector{v}_{\omega} = -7.0680 \uvecp\uvec{p} + 0.2067 \uvecq\uvec{q} km/s.

Step 2—Rotate the Perifocal Frame

The second step of this algorithm is to apply the set of coordinate transformations that converts the perifocal frame into the inertial frame. It turns out that a set of three rotations applied sequentially will accomplish this goal. These steps are shown in Fig. 50.

  1. Rotate around the \uvecw\uvec{w} axis until the \uvecp\uvec{p} axis is aligned with the node line
  2. Rotate around the node line until the \uvecw\uvec{w} axis is aligned with the ZZ axis
  3. Rotate around the ZZ axis until the \uvecp\uvec{p} axis is aligned with the XX axis

The sequence of rotations to convert from the perifocal frame to the inertial frame. Adapted from Juansempere, CC BY-SA 4.0, via Wikimedia Commons.

Figure 50:The sequence of rotations to convert from the perifocal frame to the inertial frame. Adapted from Juansempere, CC BY-SA 4.0, via Wikimedia Commons.

Step 2.1—Rotate Until \uvecp\uvec{p} is Aligned With the Node Line

By definition, the \uvecp\uvec{p} vector points towards periapsis. Therefore, it is also aligned with the eccentricity vector. If we rotate the frame around the \uvecw\uvec{w} axis until \uvecp\uvec{p} is aligned with the node line, this will align \vectore\vector{e} with \vectorN\vector{N}. This rotation is the negative of the argument of periapsis, ω\omega.

Step 2.2—Rotate Until \uvecw\uvec{w} is Aligned With the ZZ Axis

At this point, the node line and the eccentricity are aligned. Rotating around the node line changes the inclination of the orbit. When \uvecw\uvec{w} is aligned with the ZZ axis, then the inclination, ii, has been accounted for.

Step 2.3—Rotate Until \uvecp\uvec{p} is Aligned With the XX Axis

The last step is to account for the right ascension of the ascending node. Since \uvecp\uvec{p} is now aligned with the node line, we can rotate around the ZZ axis to turn the orbital plane until it aligns with the XX axis. This is the negative of the right ascension of the ascending node.

These three angles (ω\omega, ii, and Ω\Omega) are called Euler angles. Transformations based on the Euler angles are well known and can be calculated in many ways.

Python

Matlab

python
from scipy.spatial.transform import Rotation

R = Rotation.from_euler("ZXZ", [-omega, -i, -Omega])
r_rot = r_w @ R.as_matrix()
v_rot = v_w @ R.as_matrix()

In Python, the SciPy library includes a class to automatically compute the rotation matrix. The class takes the three angles and the axes about which the rotations should be done. In this case, our rotations are around the \uvecw\uvec{w} axis (the zz axis of the perifocal frame), the xx axis that is present after the first rotation, and finally, the zz axis which is present after the second rotation.

Notice that the rotation is right-handed by default, positive clockwise. Since we are reversing the rotations, the angles all have to be negative.

To actually perform the rotation, we need to multiply the position and velocity vectors in the perifocal frame by the rotation matrix. The @ symbol in Python performs matrix multiplication, instead of scalar multiplication.

diagram

orbital_elements_and_the_state_vector.m

matlab
R1 = [cos(-omega) -sin(-omega) 0; sin(-omega) cos(-omega) 0; 0 0 1];
R2 = [1 0 0; 0 cos(-i) -sin(-i); 0 sin(-i) cos(-i)];
R3 = [cos(-Omega) -sin(-Omega) 0; sin(-Omega) cos(-Omega) 0; 0 0 1];
r_rot = r_w * R1 * R2 * R3;
v_rot = v_w * R1 * R2 * R3;

In Matlab, there is no built-in way to compute rotation matrices. Instead, the easiest step is to compose the rotation matrices for each direction and multiply the position and velocity vectors by the matrices.

The order that the multiplication occurs is important! This is because the rotation has to occur first around the \uvecw\uvec{w} axis, then about the new xx axis generated by the first rotation, and finally around the new zz axis created by the second rotation. If the rotations are specified in a different order, you will not get the right result.

In addition, notice that the angles must be specified as negative, since we are reversing the rotation from the perifocal frame to the inertial frame.

In the end, we find \vectorr=\vector{r} = 1000 \uvecI\uvec{I} + 5000 \uvecJ\uvec{J} + 7000 \uvecK\uvec{K} km and \vectorv=\vector{v} = 3 \uvecI\uvec{I} + 4 \uvecJ\uvec{J} + 5 \uvecK\uvec{K} km/s. This is exactly the same as the initial condition, showing that we did the conversion correctly.