Пример #1
0
 public static double GetEccentricAnomaly(double M, double e)
 {
     if (e < 1.0)
     {
         return(Kepler.NewtonElliptical(M, e, 1));
     }
     if (e > 1.0)
     {
         return(Kepler.NewtonHyperbolic(M, e));
     }
     if (e == 1.0)
     {
         return(Kepler.NewtonParabolic(M, e, 1));
     }
     return(M);
 }
Пример #2
0
    private static double NewtonElliptical(double M, double e, int count)
    {
        double num  = M;
        double num2 = 0.0;

        for (int i = 0; i < Kepler.maxIterations * count; i++)
        {
            num2 = num - (num - e * Math.Sin(num2) - M) / (1.0 - e * Math.Cos(num2));
            if (Math.Abs(num2 - e * Math.Sin(num2) - M) < Kepler.tolerance)
            {
                return(num2);
            }
            num = num2;
        }
        if (count <= 3)
        {
            return(Kepler.NewtonElliptical(M + 1E-05, e, count + 1));
        }
        return(num2);
    }