I am wondering if somebody could help me figure out how to convert orbital state vectors from one origin to another?

Say I am running a simulation of the Earth, Moon and Sun system. When calculating the trajectories of the masses under consideration, the center of the coordinate system is the barycenter of the solar system, but for the purpose of animating this simulation, I would like to be able to convert the position vectors that I calculate every iteration into vectors that have the Earth-Moon barycenter as the origin of the coordinate system.

How would I go about doing this?


2 Answers 2


If you are using JPL's Horizons, then choose your origin as "@3" which is the Earth-Moon barycenter. Like this:

enter image description here

..and you'll get numbers for X and Y that are +/- 4,000 km roughly, which is the Earth's orbit around the Earth-Moon barycenter. Z will move a few hundred km because the Moon's orbit is so far out of the ecliptic that it pulls the Earth up and down a little.

Original answer:

The barycenter of the Earth - Moon system would be the weighted average of the two positions which is just the center of mass. If the masses of the Earth and Moon are $m_E$ and $m_M$, and their position vectors are $\mathbf{x}_E$ and $\mathbf{x}_M$, then the location of the barycenter is just:

$$\mathbf{x}_{CM} \ = \ \mathbf{x}_E\frac{m_E}{m_E+m_M} + \mathbf{x}_M\frac{m_M}{m_E+m_M}$$

So get the Earth's and Moon's position in the E-M barycenter coordinates just subtract, :

$$\mathbf{x}_{E,CM} \ = \ \mathbf{x}_E \ - \mathbf{x}_{CM}$$ $$\mathbf{x}_{M,CM} \ = \ \mathbf{x}_M \ - \mathbf{x}_{CM}$$

The earth will move around the E-M barycenter which will be inside the Earth, roughly 4,000 km from the center. The algebra can be simplified a bit but I'll leave it like this to make it clear what's going on.

Just for fun, here's a series of images of Pluto and it's moon Charon. In this case the barycenter is outside of pluto, in between the two.

enter image description here

above: Barycentric view of the Pluto–Charon system as seen by New Horizons. From here.

Here is how I do it using Skyfield in Python (for the year 2016). With Horizons you have to do some housekeeping after downloading text file outputs.

enter image description here

from skyfield.api import load
import numpy as np
import matplotlib.pyplot as plt

ephem = load('de421.bsp')

earth = ephem['earth']
moon = ephem['moon']
sun = ephem['sun']

ts = load.timescale()

days = np.arange(365.)

time = ts.utc(2016, 1, 1+days)

epos   = earth.at(time).position.km
mpos   = moon.at(time).position.km
spos   = sun.at(time).position.km

me, mm = 5.972E+24, 7.342E+22

cmpos = (epos*me + mpos*mm) / (me + mm)

epos_cm = epos - cmpos
mpos_cm = mpos - cmpos

names = ['Earth', 'Moon', 'Moon-Earth', 'Sun', 'Earth_cm', 'Moon_cm']
posns = [epos, mpos, mpos-epos, spos, epos_cm, mpos_cm]

for i, (name, pos) in enumerate(zip(names, posns)):
    plt.subplot(len(posns), 1, i+1)
    for thing in pos:
        plt.plot(days, thing)
  • $\begingroup$ Not quite! If you look at the interface of ssd.jpl.nasa.gov/horizons.cgi you will see that you can choose the origin of the cartesian coordinate system to be, for example, the bary center of the whole solar system, or if you are so minded, you can choose it to be the bary center of the Earth-Moon system (there are other options). My question is how, with a set of xyz vectors with the solar system bary center as the origin of the coordinate system, I can convert these into vectors where the Earth-Moon barycenter is origin of the coordinate system. Makes sense? $\endgroup$ Nov 16, 2016 at 11:48
  • $\begingroup$ Magnificent gif, though; can't ever have enough of Charon and Pluto doing their orbital chacha! $\endgroup$ Nov 16, 2016 at 11:50
  • $\begingroup$ I find it difficult sometimes to formulate my questions, so my apologies if I wasn't clear enough to begin with, but Sir, that is an excellent answer, and thanks for the code as well (is it open source?)!!! $\endgroup$ Nov 16, 2016 at 12:14
  • $\begingroup$ If you use python, then you just install Skyfield. For sure it's open source! It uses (essentially) the same math as Horizons but has somewhat different functionality, and you can choose different JPL ephemerides. You can search in this stackexchange, and in Astronomy SE and Satckoverflow for "Skyfield" as well. $\endgroup$
    – uhoh
    Nov 16, 2016 at 12:45
  • $\begingroup$ @HappyKoala If you have the position of the Earth-Moon barycenter relative to the solar system barycenter you just subtract. $\endgroup$
    – Kyle
    Nov 16, 2016 at 14:53

Let's say that your simulation produces the position vectors $\mathbf{r}_{bs}$, $\mathbf{r}_{be}$, and $\mathbf{r}_{bm}$ of the Sun ($s$), the Earth ($e$), and the Moon ($m$) relative to the barycenter of the solar system ($b$). It also produces the velocity vectors $\mathbf{v}_{bs}=\mathbf{\dot{r}}_{bs}$, $\mathbf{v}_{be}=\mathbf{\dot{r}}_{be}$, and $\mathbf{v}_{bm}=\mathbf{\dot{r}}_{bm}$.

If I understand your question correctly, you want to determine the position vectors $\mathbf{r}_{cs}$, $\mathbf{r}_{ce}$, and $\mathbf{r}_{cm}$ and velocity vectors $\mathbf{v}_{cs}$, $\mathbf{v}_{ce}$, and $\mathbf{v}_{cm}$ relative to the barycenter of the Earth-Moon system ($c$).

Note: I am using the subscript notation $\mathbf{r}_{be}$ to indicate the displacement vector from $b$ to $e$, and so on.

First, you need to calculate $\mathbf{r}_{bc}$, the position vector from the solar system barycenter to the Earth-Moon barycenter: $$ \mathbf{r}_{bc} = \frac{m_e\mathbf{r}_{be}+m_m\mathbf{r}_{bm}}{m_e+m_m} $$ where $m_e$ is the mass of the Earth, and $m_m$ is the mass of the Moon. Then you can calculate the position vectors $\mathbf{r}_{cs}$, $\mathbf{r}_{ce}$, and $\mathbf{r}_{cm}$ of the Sun ($s$), the Earth ($e$), and the Moon ($m$) relative to the barycenter of the Earth-Moon system ($c$) using \begin{eqnarray*} \mathbf{r}_{cs} &=& \mathbf{r}_{bs} - \mathbf{r}_{bc} \\ \mathbf{r}_{ce} &=& \mathbf{r}_{be} - \mathbf{r}_{bc} \\ \mathbf{r}_{cm} &=& \mathbf{r}_{bm} - \mathbf{r}_{bc} \end{eqnarray*} The velocity vectors are $$ \mathbf{v}_{cs} = \mathbf{\dot{r}}_{cs} = \mathbf{\dot{r}}_{bs} - \mathbf{\dot{r}}_{bc} = \mathbf{v}_{bs} - \mathbf{v}_{bc} $$ and so on, where $$ \mathbf{v}_{bc} = \mathbf{\dot{r}}_{bc} = \frac{m_e\mathbf{\dot{r}}_{be}+m_m\mathbf{\dot{r}}_{bm}}{m_e+m_m} = \frac{m_e\mathbf{v}_{be}+m_m\mathbf{v}_{bm}}{m_e+m_m} $$

Note that I also assumed that the reference frames fixed to the solar system barycenter and the Earth-Moon barycenter are not rotating relative to each other.

Hope this helps!

  • $\begingroup$ Very nice! It's good to have the everything written out completely - and nicely too! $\endgroup$
    – uhoh
    Nov 16, 2016 at 12:24
  • 1
    $\begingroup$ Thank you Christo for your input!!! I feel blessed getting two excellent answers within the time-span of an afternoon... Stackexchange is where it's at :). $\endgroup$ Nov 16, 2016 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.