The starting point for calculations involving a body in an elliptical orbit is often the mean anomaly, AM. This is the angle moved by a fictitious body in a circular orbit of the same period as the real body, the angle being reckoned in the same sense as the direction of motion of the real body from the point of closest approach (the periapsis).The quantity needed is the true anomaly, AT, which measures the angle moved by the real body since periapsis, and it is related to AM through the eccentric anomaly, AE, by Kepler's equation.
AE - (EC × SIN(AE)) = AM,
where EC is the eccentricity of the orbit. Unfortunately, this equation is not easily solved, but the solution can be approximated by a trigonometric expansion called the equation of the centre.If EC is less than about 0.1 and high precision is not required, the first term of the expansion may suffice, giving
AT = AM + (2 × EC × SIN(AM)),
where AT and AM are expressed in radians.
For more accurate work, the equation must be solved explicitly for AE, and then AT calculated from
TAN(AT/2) = ((1 + EC)/(1 - EC))0.5 × TAN(AE/2).
The routine given here solves Kepler's equation by an iterative method in which an approximate solution for AE is repeatedly refined until the error between (AE - (EC x SIN(AE))) and AM is less than a given error (10-6 radians).