5
$\begingroup$

I want to simulate the orbits of the planets from our solar system. I want to use orbital elements to calculate the current position(xyz) at a time t. The simulation doesn't have to be too exact, but the initial position of the bodies should be somewhat realistic.

Doing some research on the calculation I stumbled upon the following formula:

R,X,Y,Z-Heliocentric Distances
TA - True Anomaly
N - Longitude of the Ascending Node
w - Argument of the Perihelion

R = a * (1 - e ^ 2) / (1 + e * Cos(TA))
X = R * (Cos(N) * Cos(TA + w) - Sin(N) * Sin(TA+w)*Cos(i)
Y = R * (Sin(N) * Cos(TA+w) + Cos(N) * Sin(TA+w)) * Cos(i))
Z = R * Sin(TA+w) * Sin(i)

Source: https://www.physicsforums.com/threads/calculating-elliptic-orbits-in-cartesian-coordinates.712979/

For testing purposes I calculated the true anomaly with the help of the following calculator: http://www.jgiesen.de/kepler/kepler.html
It needs the mean anomaly and eccentricity which I took from Wikipedia. Doing some more research on the mean anomaly, I now believe that the time at which I want the position will be somehow fed into the calculation of the mean anomaly along with the time of the initial position.

Can somebody clarify for me on how to correctly calculate the position at time t with the above or a different formula. With the above formula I also think I need the initial values at a specific time.

I also want to say that I am not an astronomer and I don't have a clue on how to handle the calculation or which formula to use. The result of the calculations should mimic our solar system as closely as possible.

Thanks,
Rene Hollander

$\endgroup$
  • $\begingroup$ possible duplicate astronomy.stackexchange.com/questions/8012/… $\endgroup$ – James K Nov 30 '15 at 22:21
  • $\begingroup$ I also found that post, but the answers did not really help me to solve the Problem. $\endgroup$ – Rene8888 Nov 30 '15 at 22:50
  • $\begingroup$ If you want to simulate orbits, wouldn't you just use initial positions and velocities and proceed from there? You'll end up solving some fairly ugly differential equations, which is exactly what NASA does to get the DE epherdermes. $\endgroup$ – barrycarter Dec 1 '15 at 17:07
  • $\begingroup$ That also sounds good. I assume I have to simulate the gravitational forces to do that. If I let the simulation run for a while, wouldn't it be possible through errors during the calculation to mess up the orbits? $\endgroup$ – Rene8888 Dec 1 '15 at 17:16
2
$\begingroup$

As it happens, I was writing code for the exact same transformation last night using this memo as a reference. I haven't yet tested my implementation but the document is quite clear about what each step is doing, which pleased me greatly.

You'll have to understand the terminology to some degree; "epoch" means a reference time for which you have the orbital elements, and "considered epoch" means the time at which you're evaluating the position, for example. Other points requiring caution: the equations inconsistently drop subscripts; the use of the Newton-Raphson solver isn't particularly clear (i.e. how many times should it run)? Make sure you get the units right also.

$\endgroup$
  • $\begingroup$ Thanks for that memo. I also just (5 minutes ago) found a forum post which describes the calculation for the true anomaly: orbiter-forum.com/showthread.php?t=26682. Let's assume that I will use the orbital elements at epoch J.2000 for earth. If I start my calculation at t=0 (Perihelion) and reach Perihelion again when t=365, I will reset t to zero again to calculate the true anomaly? Did I understand that correctly? $\endgroup$ – Rene8888 Dec 1 '15 at 17:10
  • 1
    $\begingroup$ You can do that; my approach is to compute the mean anomaly as in equation (2) in the memo, then use the fmod() operation to wrap it to the [0, 2pi) range, which has the same effect. $\endgroup$ – Russell Borogove Dec 1 '15 at 17:33
  • $\begingroup$ Since a solar year is actually approximately 365.25 and a bit days, wrapping 365 to 0 will accumulate ~6 hours of error a year, which depending on your application will be either mildly irritating or catastrophic. $\endgroup$ – Russell Borogove Dec 1 '15 at 17:44
  • $\begingroup$ It's just a simple 3d python application. Even if the error would be bigger it doesn't matter. But to be save, I can calculate the orbital period with the help of Kepler's Third Law to be equal with the supplied semi-major axis and standard gravitational constant. The semi-major axis can be calculated with the help of the apogee and perigee, from which I can also calculate the eccentricity. In the end the values should be fairly accurate and I will not have problems with values from different sources. $\endgroup$ – Rene8888 Dec 1 '15 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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