Exemplo n.º 1
0
        //public static Vector4 GetAbsolutePositionForParabolicOrbit_AU()
        //{ }

        //public static Vector4 GetAbsolutePositionForHyperbolicOrbit_AU(OrbitDB orbitDB, DateTime time)
        //{

        //}

        public static double GetTrueAnomaly(OrbitDB orbit, DateTime time)
        {
            TimeSpan timeSinceEpoch = time - orbit.Epoch;

            // Don't attempt to calculate large timeframes.
            while (timeSinceEpoch > orbit.OrbitalPeriod && orbit.OrbitalPeriod.Ticks != 0)
            {
                long years = timeSinceEpoch.Ticks / orbit.OrbitalPeriod.Ticks;
                timeSinceEpoch -= TimeSpan.FromTicks(years * orbit.OrbitalPeriod.Ticks);
                orbit.Epoch    += TimeSpan.FromTicks(years * orbit.OrbitalPeriod.Ticks);
            }

            double m0 = Angle.ToRadians(orbit.MeanAnomalyAtEpoch);
            double n  = Angle.ToRadians(orbit.MeanMotion);
            double currentMeanAnomaly = OrbitMath.GetMeanAnomalyFromTime(m0, n, timeSinceEpoch.TotalSeconds);

            double eccentricAnomaly = GetEccentricAnomaly(orbit, currentMeanAnomaly);

            return(OrbitMath.TrueAnomalyFromEccentricAnomaly(orbit.Eccentricity, eccentricAnomaly));

            /*
             * var x = Math.Cos(eccentricAnomaly) - orbit.Eccentricity;
             * var y = Math.Sqrt(1 - orbit.Eccentricity * orbit.Eccentricity) * Math.Sin(eccentricAnomaly);
             * return Math.Atan2(y, x);
             */
        }