# Simulate an orbit with orbital elements

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)


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

• possible duplicate astronomy.stackexchange.com/questions/8012/… – James K Nov 30 '15 at 22:21
• I also found that post, but the answers did not really help me to solve the Problem. – Rene8888 Nov 30 '15 at 22:50
• 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. – user21 Dec 1 '15 at 17:07
• 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? – Rene8888 Dec 1 '15 at 17:16