The equations of motion are just second order ordinary differential equations. They can be solved numerically by any of the usual methods, However, for two bodies an exact solution can be found, that solution was known to Kepler. To model the trajectory you need to know the orbital period and the eccentricty (e) of the orbit.
If you know the period of orbit of a body, then the "Mean anomaly (M)" is the angle time/period *2*pi radians (it increases uniformly from zero to 2pi in one orbital period.
The find the Eccentric anomaly ("E", the angle made by the body, the center of the elliptical orbit and the point of periapsis when the body is closest to the sun) you solve $M=E-esin(E)$ (it can be solved by newton's method quickly, though convergence is fastest for roughly circular orbits.
You then know the body is on a ellipse, with the sun at one focus and you have calculated the ray on which the body is found at a given time. This gives you the position of the body.
There is a rough implementation of this in a python gist
No comments:
Post a Comment