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;
}
Related posts:
- Astronomical calculations in C#: Finding the angular diameter of the Sun The method of find the angular diameter of the Sun...
- Astronomical calculations in C#: Finding the distance to the Sun Finding the distance to the Sun is quite straightforward once...
- Astronomical calculations in C#: Calculating the Sun’s position To find the position of the Sun, the first thing...
- Astronomical calculations in C#: Finding the position of the planets Finding the position of a planet is a rather involved...
- Astronomical calculations in C#: Finding the magnitude of a planet This calculation is based on the position calculation, but also...
Related posts brought to you by Yet Another Related Posts Plugin.
Serge Meunier is a software developer living in Cape Town, South Africa. He loves programming, fencing, philosophy, feeding his internet addiction, and, of course, dogs.
Comments