コード例 #1
0
        private static Distance GetMoonDistance(DateTime d, double[] values)
        {
            //Ch 47
            double JDE = JulianConversions.GetJulian(d); //Get julian
            double T   = (JDE - 2451545) / 36525;        //Get dynamic time.

            double D = values[1];
            double M = values[2];
            double N = values[3];
            double F = values[4];

            double dist = 385000.56 + (MeeusTables.Moon_Periodic_Er(D, M, N, F, T) / 1000);

            return(new Distance(dist));
        }
コード例 #2
0
ファイル: SunCalculations.cs プロジェクト: Punchcards/Sphere
        private static DateTime Get_Soltice_Equinox_From_JDE0(double JDE0, double offset)
        {
            //Get Event Ch 27.
            double   T   = (JDE0 - 2451545.0) / 36525;
            double   W   = (35999.373 * Math.PI / 180) * T - (2.47 * Math.PI / 180);
            double   ang = 1 + .0334 * Math.Cos(W) + .0007 * Math.Cos(2 * W);
            double   sum = MeeusTables.Equinox_Solstice_Sum_of_S(T);
            double   JDE = JDE0 + ((.00001) * sum / ang);
            DateTime?d   = JulianConversions.GetDate_FromJulian(JDE);

            if (d.HasValue)
            {
                return(JulianConversions.GetDate_FromJulian(JDE).Value.AddHours(offset));
            }
            return(new DateTime()); //Julian limit exceeded, return empty DateTime
        }
コード例 #3
0
        /// <summary>
        /// Get moons lat/long in radians (Ch 47).
        /// </summary>
        /// <param name="LDMNF">L,D,M,N,F</param>
        /// <param name="T">Dynamic Time</param>
        /// <returns>Lat[0], Long[1]</returns>
        private static double[] Get_Moon_Coordinates(double[] LDMNF, double T)
        {
            //Reference Ch 47.
            double lat   = LDMNF[0] + (MeeusTables.Moon_Periodic_El(LDMNF[0], LDMNF[1], LDMNF[2], LDMNF[3], LDMNF[4], T) / 1000000);
            double longi = MeeusTables.Moon_Periodic_Eb(LDMNF[0], LDMNF[1], LDMNF[2], LDMNF[3], LDMNF[4], T) / 1000000;

            lat %= 360;
            if (lat < 0)
            {
                lat += 360;
            }

            //Convert to radians
            double l = rad * lat;   // longitude
            double b = rad * longi; // latitude

            return(new double[] { l, b });
        }
コード例 #4
0
        /// <summary>
        /// Gets moon distance (Ch 47).
        /// </summary>
        /// <param name="d">DateTime</param>
        /// <param name="offset">UTC offset in hours</param>
        /// <returns>Distance</returns>
        public static Distance GetMoonDistance(DateTime d, double offset)
        {
            //Ch 47
            offset *= -1;
            double julianOffset = offset * .04166667;
            double JDE          = JulianConversions.GetJulian(d) + julianOffset; //Get julian
            double T            = (JDE - 2451545) / 36525;                       //Get dynamic time.

            double[] values = Get_Moon_LDMNF(T);

            double D = values[1];
            double M = values[2];
            double N = values[3];
            double F = values[4];

            //Ch 47 distance formula
            double dist = 385000.56 + (MeeusTables.Moon_Periodic_Er(D, M, N, F, T) / 1000);

            return(new Distance(dist));
        }
コード例 #5
0
        //v1.1.3 Formulas
        //The following formulas are either additions
        //or conversions of SunCalcs formulas into Meeus

        /// <summary>
        /// Grabs Perigee or Apogee of Moon based on specified time.
        /// Results will return event just before, or just after specified DateTime
        /// </summary>
        /// <param name="d">DateTime</param>
        /// <param name="md">Event Type</param>
        /// <returns>PerigeeApogee</returns>
        private static PerigeeApogee MoonPerigeeOrApogee(DateTime d, MoonDistanceType md)
        {
            //Perigee & Apogee Algorithms from Jean Meeus Astronomical Algorithms Ch. 50

            //50.1
            //JDE = 2451534.6698 + 27.55454989 * k
            //                     -0.0006691 * Math.Pow(T,2)
            //                     -0.000.01098 * Math.Pow(T,3)
            //                     -0.0000000052 * Math.Pow(T,4)

            //50.2
            //K approx = (yv - 1999.97)*13.2555
            //yv is the year + percentage of days that have occured in the year. 1998 Oct 1 is approx 1998.75
            //k ending in .0 represent perigee and .5 apogee. Anything > .5 is an error.

            //50.3
            //T = k/1325.55

            double yt = 365; //days in year

            if (DateTime.IsLeapYear(d.Year))
            {
                yt = 366;
            }                                     //days in year if leap year
            double f  = d.DayOfYear / yt;         //Get percentage of year that as passed
            double yv = d.Year + f;               //add percentage of year passed to year.
            double k  = (yv - 1999.97) * 13.2555; //find approximate k using formula 50.2

            //Set k decimal based on apogee or perigee
            if (md == MoonDistanceType.Apogee)
            {
                k = Math.Floor(k) + .5;
            }
            else
            {
                k = Math.Floor(k);
            }

            //Find T using formula 50.3
            double T = k / 1325.55;
            //Find JDE using formula 50.1
            double JDE = 2451534.6698 + 27.55454989 * k -
                         0.0006691 * Math.Pow(T, 2) -
                         0.00001098 * Math.Pow(T, 3) -
                         0.0000000052 * Math.Pow(T, 4);

            //Find Moon's mean elongation at time JDE.
            double D = 171.9179 + 335.9106046 * k -
                       0.0100383 * Math.Pow(T, 2) -
                       0.00001156 * Math.Pow(T, 3) +
                       0.000000055 * Math.Pow(T, 4);

            //Find Sun's mean anomaly at time JDE
            double M = 347.3477 + 27.1577721 * k -
                       0.0008130 * Math.Pow(T, 2) -
                       0.0000010 * Math.Pow(T, 3);


            //Find Moon's argument of latitude at Time JDE
            double F = 316.6109 + 364.5287911 * k -
                       0.0125053 * Math.Pow(T, 2) -
                       0.0000148 * Math.Pow(T, 3);

            //Normalize DMF to a 0-360 degree number
            D %= 360;
            if (D < 0)
            {
                D += 360;
            }
            M %= 360;
            if (M < 0)
            {
                M += 360;
            }
            F %= 360;
            if (F < 0)
            {
                F += 360;
            }

            //Convert DMF to radians
            D = D * Math.PI / 180;
            M = M * Math.PI / 180;
            F = F * Math.PI / 180;
            double termsA;

            //Find Terms A from Table 50.A
            if (md == MoonDistanceType.Apogee)
            {
                termsA = MeeusTables.ApogeeTermsA(D, M, F, T);
            }
            else
            {
                termsA = MeeusTables.PerigeeTermsA(D, M, F, T);
            }
            JDE += termsA;
            double termsB;

            if (md == MoonDistanceType.Apogee)
            {
                termsB = MeeusTables.ApogeeTermsB(D, M, F, T);
            }
            else
            {
                termsB = MeeusTables.PerigeeTermsB(D, M, F, T);
            }
            //Convert julian back to date
            DateTime date = JulianConversions.GetDate_FromJulian(JDE).Value;
            //Obtain distance
            Distance dist = GetMoonDistance(date);

            PerigeeApogee ap = new PerigeeApogee(date, termsB, dist);

            return(ap);
        }