For an orbiting body, the anomaly is the angle between the the semi-major axis and the position of the body in the orbit. Since the vast majority of orbits are not quite true circles, but are instead elliptical, we have a mean anomaly and an eccentric anomaly.

The mean anomaly is the anomaly if the object in question was orbiting in a perfect circle, and can be found using Kepler’s equation

MA = E – esin(E).

The eccentric anomaly is the anomaly of the elliptical orbit, and gives a more realistic value.

Finding the eccentric anomaly is based on finding the mean anomaly, and then correcting for the eccentricity. The function is a recursive function, that takes a guess at the value, and then refines the value, recursively, until the required accuracy is achieved.

		public static double CalcEccentricAnomaly(double fEGuess, double fMA, double fEcc, double fAcc)
		{
			//Calc Ecctrentric Anomaly to specified accuracy
			double fDelta;
			double fDeltaE;
			double fE;
			double fETmp;
			double fEG;

			fEG = fEGuess;

			fDelta = fEG - (fEcc * Math.Sin(fEG)) - fMA;
			if (Math.Abs(fDelta) > fAcc)
			{
				fDeltaE = (fDelta / (1.0 - (fEcc * Math.Cos(fEG))));
				fETmp = fEG - fDeltaE;
				fE = CalcEccentricAnomaly(fETmp, fMA, fEcc, fAcc);
			}
			else
			{
				fE = fEGuess;
			}
			return fE;
		}
Share