You can get the distances between any 2 solar system objects, including all planets, most moons, hundreds of thousands of asteroids & comets, and lots of spacecraft by sending an e-mail to JPL Horizons at the following address:
horizons@ssd.jpl.nasa.gov
put the word
job in the subject line
and a modified version of this in the body:
!$$SOF
EMAIL_ADDR=''
START_TIME = '2029-Apr-01 00:00:00'
STOP_TIME = '2029-Apr-01 00:00:01'
TABLE_TYPE = 'Vector'
REF_PLANE = 'Ecliptic'
CENTER = '@010'
COMMAND='199'
!$$EOF
Change your start time and stop time to whatever you want. Notice that stop time is 1 second more than start time.
in Center =
you need the @ sign, then put in an object id
in Command =
you just need the object id
both need to be in single quotes
Object id list:
010: Sun
199: Mercury
299: Venus
399: Earth
etc,ect...
999: Pluto
301: Earth Moon
401 & 402: Mars moons
501-5xx: Jupiter Moons, etc
For a complete list, visit the JPL Horizons web page.
So in the above example, I asked for Mercury with respect to the Sun. Horizons automated system took less than 20 seconds to send me a reply e-mail that contained the following data:
*******************************************************************************
$$SOE
2462227.500000000 = A.D. 2029-Apr-01 00:00:00.0000 (CT)
3.983419164516005E+07 2.717340591298079E+07 -1.432368585167380E+06 -3.700246350807901E+01 4.235721524755920E+01 6.855282109693581E+00
1.609151534147640E+02 4.824114937165917E+07 -6.898523657281064E+00
$$EOE
*******************************************************************************
Notice the numbers I boldfaced. They are the x-component of the distance, the y-component of the distance, and the z-component of the distance expressed in kilometers. The next 3 numbers are velocity components.
from these numbers, you can come up with a distance
d=\sqrt {x^2+y^2+z^2}
which equals 48241149.3716592 kilometers in the above example.