# Computing Planetary Positions

Shortly, I will be beginning my third year at University in Computer Science, I am a software developer and I will be required to work on a final year project.

My idea for my final year project is to write a desktop application which would allow the user to specify a date/time and it would return all of the positions of the planets at that point in time.

I was hoping someone could point me in the right direction of how I would begin to do the math or calculate this, as I'm aware that position is relative and a bit open ended - any scope refinements to my project would be gladly accepted too as I'd like to incorporate other things.

Just to reiterate: This is not a programming question, and I'm not asking for someone to 'do my project for me' but any helpful pointers would be appreciated.

-

I would take a look at Stellarium, its an opensource application that does the very same thing. You could read the code, which I believe for the most part is in C++.

-
Thanks for the recommendation! :) – AdamNumberFive Mar 5 '12 at 13:32

If you want to start from zero, that is, from the maths itself, there is an often cited book, Astronomical Algorithms by Jean Meeus.

You can also look into the scientific models of the Solar System, such as the French VSOP (Variations Séculaires des Orbites Planétaires) or NASA's Jet Propulsion Laboratory Development Ephemeris.

I don't recommend looking at existing software, unless you just want to provide a user interface to some other people's library. In that case, there are the USNO's NOVAS library, the pyEphem/ephem Python library and several others.

-
Thanks for pointing me in the direction of relevant materials, much appreciated! – AdamNumberFive Mar 5 '12 at 13:33

I can't point you to any specific algorithms; but what you're asking about are ephemeris computations.

The challenge in these is that over long periods of time perturbations caused by gravitational interactions between all the planets and moons add up and you can no longer treat the problem as a collection of objects moving in Keplerian orbits. As a result instead of being able to just run simple formulas you have to iteratively compute huge numbers of tiny steps factoring in the gravitational pull of every object on every other object. I don't know what timescale/precision level this begins to become significant.

Over much longer time periods uncertainty in the exact positions of the planets makes predictions impossible. Over several hundred million years shifting the position of a single planet by a nanometer will result in completely different orbital configurations at the end of the computation.

-
Hi Dan, could you suggest a more realistic problem that could be tackled with Software Development if this one is slightly....crazy. I'm still very much in the design phase at the moment and am very much still refining my idea. – AdamNumberFive Mar 5 '12 at 13:34
@AdLib That's a very open ended question and not something I feel I could answer. I'm also not sure the problem you asked is beyond the scope of a final year project. Unless the bulk of your effort is put into visualization a Keplerian model probably isn't sufficient. A full on general relativistic perturbative model almost certainly is (due to the need to learn GR if nothing else). I don't have a good feel on where a Newtonian perturbative model would fall. You probably need to talk with someone in your schools astronomy faculty to scope that. – Dan Neely Mar 5 '12 at 13:45
@AdLib Also on the unknown list for trying to answer your question is how big your final year project is supposed to be. My estimates above were made assuming it's somewhere between 1/3 and 1/2 of your final years work. – Dan Neely Mar 5 '12 at 13:48
An ephemeris calculator should be simple enough to do, if you have a good model and are not afraid of the math. The standard models used for generating ephemeris offer reasonable accuracy at least for a few decades around their epoch. – Daggerstab Mar 5 '12 at 19:44
Hey Dan, I do appreciate your response, I know the question is a little open and indirect. My project is worth 60% of my grade and basically in my head (I know right?) I had an educational style tool for kids but with some advanced calculations like this ephemeris calculator that Daggerstab mentioned. This is the direction I would like to take it in, and I'm not afraid of math - I'm just not an expert at Physics unfortunately, its a big interest to me and I'd like to work with it. Thanks guys. – AdamNumberFive Mar 6 '12 at 14:55

I recently created my own planetarium/ephemeris, here are some (rambling) thoughts:

There are two kinds of time that can be used as input to your program: Ephemeris time (coordinate time), and TAI/UTC (proper atomic time). Coordinate time is the independent variable of the equations of motion.

The input to the mentioned VSOP and JPL ephemerides is a coordinate time, which is not the same as the UTC date and time on Earth. If you wish calculate the positions of the planets as a function of the actual time, you must first convert the time into a suitable coordinate time. TE405 is an open source project that converts TAI to the Ephemeris time used in the JPL DE405 ephemeris.

If you want reasonably accurate results, you must numerically integrate the Einstein-Infeld-Hoffmann equations of motion, including the harmonic coefficients of the gravitational potentials of the Sun, Mercury, Earth, Jupiter, and Saturn. You will need to integrate the orbits of the larger minor planets (Ceres, Pallas, Vesta) as well. Numerical integration of the relativistic equations is very computationally intensive, and requires quad precision. NASA uses special hardware, everyone else uses a high precision software library. Unless you know GR, it's best just to use a Chebyshev approximation

Precision is real problem. Intel processors have 80 bit FP registers, but Windows only supports 64 bit FP types. By coding in assembler you can retain that precision.

Once you have the positions of the planets it's not that much more work to add a 3d visualization of the solar system using DX or OPENGL. For a realistic background use the Hipparcos, or Yale bright star catalogs. After that, go to the minor planet database and download the orbits of the first 300,000-400,000 minor planets in CSV format, any modern GPU will be able to render (but not animate) them in real time. Get a 3d monitor and prepare to be blown away.

If you want to reproduce real astronomical observations you will need to account for precession/nutation/polar motion, etc.

To replicate Lunar ranging experiments, use the GTOPO30 digital elevation model.

-

Each planet has a period of"grand revolution." the ancients knew these figures, and today they may be helpful to you. The number for saturn, for example, is 59 years. This means that it returns to each postion every 59 years. Jupiter is 83 years, Mars and Mercury are 79 years.

Depending on the number of leap years within those periods you may be off by a degree.. maybe 2, but that correction can be found.

Now, it ain't calculus!! but it will give you the information you are seeking.

-