public static AASLunarEclipseDetails CalculateLunar(double k)
        {
#if DEBUG
            double intp          = 0;
            bool   bSolarEclipse = (AASMath.modF(k, ref intp) == 0);
            if (bSolarEclipse)
            {
                throw new NotSupportedException("bSolarEclipse must be false for the operation to complete successfully.");
            }
#endif

            double Mdash = 0;
            AASSolarEclipseDetails solarDetails = Calculate(k, ref Mdash);

            //What will be the return value
            AASLunarEclipseDetails details = new AASLunarEclipseDetails
            {
                bEclipse             = solarDetails.Flags != 0,
                F                    = solarDetails.F,
                gamma                = solarDetails.gamma,
                TimeOfMaximumEclipse = solarDetails.TimeOfMaximumEclipse,
                u                    = solarDetails.u
            };

            if (details.bEclipse)
            {
                details.PenumbralRadii = 1.2848 + details.u;
                details.UmbralRadii    = 0.7403 - details.u;
                double fgamma = Math.Abs(details.gamma);
                details.PenumbralMagnitude = (1.5573 + details.u - fgamma) / 0.5450;
                details.UmbralMagnitude    = (1.0128 - details.u - fgamma) / 0.5450;

                double p = 1.0128 - details.u;
                double t = 0.4678 - details.u;
                double n = 0.5458 + 0.0400 * Math.Cos(Mdash);

                double gamma2 = details.gamma * details.gamma;
                double p2     = p * p;
                if (p2 >= gamma2)
                {
                    details.PartialPhaseSemiDuration = 60 / n * Math.Sqrt(p2 - gamma2);
                }

                double t2 = t * t;
                if (t2 >= gamma2)
                {
                    details.TotalPhaseSemiDuration = 60 / n * Math.Sqrt(t2 - gamma2);
                }

                double h  = 1.5573 + details.u;
                double h2 = h * h;
                if (h2 >= gamma2)
                {
                    details.PartialPhasePenumbraSemiDuration = 60 / n * Math.Sqrt(h2 - gamma2);
                }
            }

            return(details);
        }
Ejemplo n.º 2
0
        public void Get(ref long Year, ref long Month, ref long Day, ref long Hour, ref long Minute, ref double Second)
        {
            double JD    = _mDblJulian + 0.5;
            double tempZ = 0;
            double F     = AASMath.modF(JD, ref tempZ);
            long   Z     = (long)tempZ;
            long   A;

            //There is a difference here between the Meeus implementation and this one
            //if Z >= 2299161 The Meeus implementation automatically assumes the Gregorian Calendar
            //came into effect on 15 October 1582 (JD: 2299161), while the CAADate
            //implementation has a "m_bGregorianCalendar" value to decide if the date
            //was specified in the Gregorian or Julian Calendars. This difference
            //means in effect that CAADate fully supports a propalactive version of the
            //Julian calendar. This allows you to construct Julian dates after the Papal
            //reform in 1582. This is useful if you want to construct dates in countries
            //which did not immediately adapt the Gregorian calendar
            if (_mBGregorianCalendar)
            {
                long alpha = INT((Z - 1867216.25) / 36524.25);
                A = Z + 1 + alpha - INT(INT(alpha) / 4.0);
            }
            else
            {
                A = Z;
            }

            long B = A + 1524;
            long C = INT((B - 122.1) / 365.25);
            long D = INT(365.25 * C);
            long E = INT((B - D) / 30.6001);

            double dblDay = B - D - INT(30.6001 * E) + F;

            Day = (long)dblDay;

            if (E < 14)
            {
                Month = E - 1;
            }
            else
            {
                Month = E - 13;
            }

            if (Month > 2)
            {
                Year = C - 4716;
            }
            else
            {
                Year = C - 4715;
            }

            F      = AASMath.modF(dblDay, ref tempZ);
            Hour   = INT(F * 24);
            Minute = INT((F - Hour / 24.0) * 1440.0);
            Second = (F - Hour / 24.0 - Minute / 1440.0) * 86400.0;
        }
Ejemplo n.º 3
0
        public static AASSolarEclipseDetails CalculateSolar(double k)
        {
#if DEBUG
            double intp          = 0;
            bool   bSolarEclipse = (AASMath.modF(k, ref intp) == 0);
            if (!bSolarEclipse)
            {
                throw new NotSupportedException("bSolarEclipse must be true for the operation to complete successfully.");
            }
#endif

            double Mdash = 0;
            return(Calculate(k, ref Mdash));
        }
Ejemplo n.º 4
0
        private static AASSolarEclipseDetails Calculate(double k, ref double Mdash)
        {
            //Are we looking for a solar or lunar eclipse
            double intp          = 0;
            bool   bSolarEclipse = (AASMath.modF(k, ref intp) == 0);

            //What will be the return value
            AASSolarEclipseDetails details = new AASSolarEclipseDetails();

            //convert from K to T
            double T  = k / 1236.85;
            double T2 = T * T;
            double T3 = T2 * T;
            double T4 = T3 * T;

            double E = 1 - 0.002516 * T - 0.0000074 * T2;

            double M = AASCoordinateTransformation.MapTo0To360Range(2.5534 + 29.10535670 * k - 0.0000014 * T2 - 0.00000011 * T3);

            M = AASCoordinateTransformation.DegreesToRadians(M);

            Mdash = AASCoordinateTransformation.MapTo0To360Range(201.5643 + 385.81693528 * k + 0.0107582 * T2 + 0.00001238 * T3 - 0.000000058 * T4);
            Mdash = AASCoordinateTransformation.DegreesToRadians(Mdash);

            double omega = AASCoordinateTransformation.MapTo0To360Range(124.7746 - 1.56375588 * k + 0.0020672 * T2 + 0.00000215 * T3);

            omega = AASCoordinateTransformation.DegreesToRadians(omega);

            double F = AASCoordinateTransformation.MapTo0To360Range(160.7108 + 390.67050284 * k - 0.0016118 * T2 - 0.00000227 * T3 + 0.00000001 * T4);

            details.F = F;
            double Fdash = F - 0.02665 * Math.Sin(omega);

            F     = AASCoordinateTransformation.DegreesToRadians(F);
            Fdash = AASCoordinateTransformation.DegreesToRadians(Fdash);

            //Do the first check to see if we have an eclipse
            if (Math.Abs(Math.Sin(F)) > 0.36)
            {
                return(details);
            }

            double A1 = AASCoordinateTransformation.MapTo0To360Range(299.77 + 0.107408 * k - 0.009173 * T2);

            A1 = AASCoordinateTransformation.DegreesToRadians(A1);

            details.TimeOfMaximumEclipse = AASMoonPhases.MeanPhase(k);

            double DeltaJD = 0;

            if (bSolarEclipse)
            {
                DeltaJD += -0.4075 * Math.Sin(Mdash) +
                           0.1721 * E * Math.Sin(M);
            }
            else
            {
                DeltaJD += -0.4065 * Math.Sin(Mdash) +
                           0.1727 * E * Math.Sin(M);
            }
            DeltaJD += 0.0161 * Math.Sin(2 * Mdash) +
                       -0.0097 * Math.Sin(2 * Fdash) +
                       0.0073 * E * Math.Sin(Mdash - M) +
                       -0.0050 * E * Math.Sin(Mdash + M) +
                       -0.0023 * Math.Sin(Mdash - 2 * Fdash) +
                       0.0021 * E * Math.Sin(2 * M) +
                       0.0012 * Math.Sin(Mdash + 2 * Fdash) +
                       0.0006 * E * Math.Sin(2 * Mdash + M) +
                       -0.0004 * Math.Sin(3 * Mdash) +
                       -0.0003 * E * Math.Sin(M + 2 * Fdash) +
                       0.0003 * Math.Sin(A1) +
                       -0.0002 * E * Math.Sin(M - 2 * Fdash) +
                       -0.0002 * E * Math.Sin(2 * Mdash - M) +
                       -0.0002 * Math.Sin(omega);

            details.TimeOfMaximumEclipse += DeltaJD;

            double P = 0.2070 * E * Math.Sin(M) +
                       0.0024 * E * Math.Sin(2 * M) +
                       -0.0392 * Math.Sin(Mdash) +
                       0.0116 * Math.Sin(2 * Mdash) +
                       -0.0073 * E * Math.Sin(Mdash + M) +
                       0.0067 * E * Math.Sin(Mdash - M) +
                       0.0118 * Math.Sin(2 * Fdash);

            double Q = 5.2207 +
                       -0.0048 * E * Math.Cos(M) +
                       0.0020 * E * Math.Cos(2 * M) +
                       -0.3299 * Math.Cos(Mdash) +
                       -0.0060 * E * Math.Cos(Mdash + M) +
                       0.0041 * E * Math.Cos(Mdash - M);

            double W = Math.Abs(Math.Cos(Fdash));

            details.gamma = (P * Math.Cos(Fdash) + Q * Math.Sin(Fdash)) * (1 - 0.0048 * W);

            details.u = 0.0059 +
                        0.0046 * E * Math.Cos(M) +
                        -0.0182 * Math.Cos(Mdash) +
                        0.0004 * Math.Cos(2 * Mdash) +
                        -0.0005 * Math.Cos(M + Mdash);

            //Check to see if the eclipse is visible from the Earth's surface
            if (Math.Abs(details.gamma) > (1.5433 + details.u))
            {
                return(details);
            }

            //We have an eclipse at this time
            details.bEclipse = true;

            //In the case of a partial eclipse, calculate its magnitude
            double fgamma = Math.Abs(details.gamma);

            if (((fgamma > 0.9972) && (fgamma < 1.5433 + details.u)))
            {
                details.GreatestMagnitude = (1.5433 + details.u - fgamma) / (0.5461 + 2 * details.u);
            }

            return(details);
        }
Ejemplo n.º 5
0
        public static double TruePhase(double k)
        {
            //What will be the return value
            double JD = MeanPhase(k);

            //convert from K to T
            double T  = k / 1236.85;
            double T2 = T * T;
            double T3 = T2 * T;
            double T4 = T3 * T;

            double E  = 1 - 0.002516 * T - 0.0000074 * T2;
            double E2 = E * E;

            double M = AASCoordinateTransformation.MapTo0To360Range(2.5534 + 29.10535670 * k - 0.0000014 * T2 - 0.00000011 * T3);

            M = AASCoordinateTransformation.DegreesToRadians(M);
            double Mdash = AASCoordinateTransformation.MapTo0To360Range(201.5643 + 385.81693528 * k + 0.0107582 * T2 + 0.00001238 * T3 - 0.000000058 * T4);

            Mdash = AASCoordinateTransformation.DegreesToRadians(Mdash);
            double F = AASCoordinateTransformation.MapTo0To360Range(160.7108 + 390.67050284 * k - 0.0016118 * T2 - 0.00000227 * T3 + 0.000000011 * T4);

            F = AASCoordinateTransformation.DegreesToRadians(F);
            double omega = AASCoordinateTransformation.MapTo0To360Range(124.7746 - 1.56375588 * k + 0.0020672 * T2 + 0.00000215 * T3);

            omega = AASCoordinateTransformation.DegreesToRadians(omega);
            double A1 = AASCoordinateTransformation.MapTo0To360Range(299.77 + 0.107408 * k - 0.009173 * T2);

            A1 = AASCoordinateTransformation.DegreesToRadians(A1);
            double A2 = AASCoordinateTransformation.MapTo0To360Range(251.88 + 0.016321 * k);

            A2 = AASCoordinateTransformation.DegreesToRadians(A2);
            double A3 = AASCoordinateTransformation.MapTo0To360Range(251.83 + 26.651886 * k);

            A3 = AASCoordinateTransformation.DegreesToRadians(A3);
            double A4 = AASCoordinateTransformation.MapTo0To360Range(349.42 + 36.412478 * k);

            A4 = AASCoordinateTransformation.DegreesToRadians(A4);
            double A5 = AASCoordinateTransformation.MapTo0To360Range(84.66 + 18.206239 * k);

            A5 = AASCoordinateTransformation.DegreesToRadians(A5);
            double A6 = AASCoordinateTransformation.MapTo0To360Range(141.74 + 53.303771 * k);

            A6 = AASCoordinateTransformation.DegreesToRadians(A6);
            double A7 = AASCoordinateTransformation.MapTo0To360Range(207.14 + 2.453732 * k);

            A7 = AASCoordinateTransformation.DegreesToRadians(A7);
            double A8 = AASCoordinateTransformation.MapTo0To360Range(154.84 + 7.306860 * k);

            A8 = AASCoordinateTransformation.DegreesToRadians(A8);
            double A9 = AASCoordinateTransformation.MapTo0To360Range(34.52 + 27.261239 * k);

            A9 = AASCoordinateTransformation.DegreesToRadians(A9);
            double A10 = AASCoordinateTransformation.MapTo0To360Range(207.19 + 0.121824 * k);

            A10 = AASCoordinateTransformation.DegreesToRadians(A10);
            double A11 = AASCoordinateTransformation.MapTo0To360Range(291.34 + 1.844379 * k);

            A11 = AASCoordinateTransformation.DegreesToRadians(A11);
            double A12 = AASCoordinateTransformation.MapTo0To360Range(161.72 + 24.198154 * k);

            A12 = AASCoordinateTransformation.DegreesToRadians(A12);
            double A13 = AASCoordinateTransformation.MapTo0To360Range(239.56 + 25.513099 * k);

            A13 = AASCoordinateTransformation.DegreesToRadians(A13);
            double A14 = AASCoordinateTransformation.MapTo0To360Range(331.55 + 3.592518 * k);

            A14 = AASCoordinateTransformation.DegreesToRadians(A14);

            //convert to radians
            double kint  = 0;
            double kfrac = AASMath.modF(k, ref kint);

            if (kfrac < 0)
            {
                kfrac = 1 + kfrac;
            }
            if (kfrac == 0) //New Moon
            {
                double DeltaJD = -0.40720 * Math.Sin(Mdash) +
                                 0.17241 * E * Math.Sin(M) +
                                 0.01608 * Math.Sin(2 * Mdash) +
                                 0.01039 * Math.Sin(2 * F) +
                                 0.00739 * E * Math.Sin(Mdash - M) +
                                 -0.00514 * E * Math.Sin(Mdash + M) +
                                 0.00208 * E2 * Math.Sin(2 * M) +
                                 -0.00111 * Math.Sin(Mdash - 2 * F) +
                                 -0.00057 * Math.Sin(Mdash + 2 * F) +
                                 0.00056 * E * Math.Sin(2 * Mdash + M) +
                                 -0.00042 * Math.Sin(3 * Mdash) +
                                 0.00042 * E * Math.Sin(M + 2 * F) +
                                 0.00038 * E * Math.Sin(M - 2 * F) +
                                 -0.00024 * E * Math.Sin(2 * Mdash - M) +
                                 -0.00017 * Math.Sin(omega) +
                                 -0.00007 * Math.Sin(Mdash + 2 * M) +
                                 0.00004 * Math.Sin(2 * Mdash - 2 * F) +
                                 0.00004 * Math.Sin(3 * M) +
                                 0.00003 * Math.Sin(Mdash + M - 2 * F) +
                                 0.00003 * Math.Sin(2 * Mdash + 2 * F) +
                                 -0.00003 * Math.Sin(Mdash + M + 2 * F) +
                                 0.00003 * Math.Sin(Mdash - M + 2 * F) +
                                 -0.00002 * Math.Sin(Mdash - M - 2 * F) +
                                 -0.00002 * Math.Sin(3 * Mdash + M) +
                                 0.00002 * Math.Sin(4 * Mdash);
                JD += DeltaJD;
            }
            else if ((kfrac == 0.25) || (kfrac == 0.75)) //First Quarter or Last Quarter
            {
                double DeltaJD = -0.62801 * Math.Sin(Mdash) +
                                 0.17172 * E * Math.Sin(M) +
                                 -0.01183 * E * Math.Sin(Mdash + M) +
                                 0.00862 * Math.Sin(2 * Mdash) +
                                 0.00804 * Math.Sin(2 * F) +
                                 0.00454 * E * Math.Sin(Mdash - M) +
                                 0.00204 * E2 * Math.Sin(2 * M) +
                                 -0.00180 * Math.Sin(Mdash - 2 * F) +
                                 -0.00070 * Math.Sin(Mdash + 2 * F) +
                                 -0.00040 * Math.Sin(3 * Mdash) +
                                 -0.00034 * E * Math.Sin(2 * Mdash - M) +
                                 0.00032 * E * Math.Sin(M + 2 * F) +
                                 0.00032 * E * Math.Sin(M - 2 * F) +
                                 -0.00028 * E2 * Math.Sin(Mdash + 2 * M) +
                                 0.00027 * E * Math.Sin(2 * Mdash + M) +
                                 -0.00017 * Math.Sin(omega) +
                                 -0.00005 * Math.Sin(Mdash - M - 2 * F) +
                                 0.00004 * Math.Sin(2 * Mdash + 2 * F) +
                                 -0.00004 * Math.Sin(Mdash + M + 2 * F) +
                                 0.00004 * Math.Sin(Mdash - 2 * M) +
                                 0.00003 * Math.Sin(Mdash + M - 2 * F) +
                                 0.00003 * Math.Sin(3 * M) +
                                 0.00002 * Math.Sin(2 * Mdash - 2 * F) +
                                 0.00002 * Math.Sin(Mdash - M + 2 * F) +
                                 -0.00002 * Math.Sin(3 * Mdash + M);
                JD += DeltaJD;

                double W = 0.00306 - 0.00038 * E * Math.Cos(M) + 0.00026 * Math.Cos(Mdash) - 0.00002 * Math.Cos(Mdash - M) + 0.00002 * Math.Cos(Mdash + M) + 0.00002 * Math.Cos(2 * F);
                if (kfrac == 0.25) //First quarter
                {
                    JD += W;
                }
                else
                {
                    JD -= W;
                }
            }
            else if (kfrac == 0.5) //Full Moon
            {
                double DeltaJD = -0.40614 * Math.Sin(Mdash) +
                                 0.17302 * E * Math.Sin(M) +
                                 0.01614 * Math.Sin(2 * Mdash) +
                                 0.01043 * Math.Sin(2 * F) +
                                 0.00734 * E * Math.Sin(Mdash - M) +
                                 -0.00514 * E * Math.Sin(Mdash + M) +
                                 0.00209 * E2 * Math.Sin(2 * M) +
                                 -0.00111 * Math.Sin(Mdash - 2 * F) +
                                 -0.00057 * Math.Sin(Mdash + 2 * F) +
                                 0.00056 * E * Math.Sin(2 * Mdash + M) +
                                 -0.00042 * Math.Sin(3 * Mdash) +
                                 0.00042 * E * Math.Sin(M + 2 * F) +
                                 0.00038 * E * Math.Sin(M - 2 * F) +
                                 -0.00024 * E * Math.Sin(2 * Mdash - M) +
                                 -0.00017 * Math.Sin(omega) +
                                 -0.00007 * Math.Sin(Mdash + 2 * M) +
                                 0.00004 * Math.Sin(2 * Mdash - 2 * F) +
                                 0.00004 * Math.Sin(3 * M) +
                                 0.00003 * Math.Sin(Mdash + M - 2 * F) +
                                 0.00003 * Math.Sin(2 * Mdash + 2 * F) +
                                 -0.00003 * Math.Sin(Mdash + M + 2 * F) +
                                 0.00003 * Math.Sin(Mdash - M + 2 * F) +
                                 -0.00002 * Math.Sin(Mdash - M - 2 * F) +
                                 -0.00002 * Math.Sin(3 * Mdash + M) +
                                 0.00002 * Math.Sin(4 * Mdash);
                JD += DeltaJD;
            }
            else
            {
                throw new NotSupportedException("The calculated lunar angular distance is invalid.");
            }

            //Additional corrections for all phases
            double DeltaJD2 = 0.000325 * Math.Sin(A1) +
                              0.000165 * Math.Sin(A2) +
                              0.000164 * Math.Sin(A3) +
                              0.000126 * Math.Sin(A4) +
                              0.000110 * Math.Sin(A5) +
                              0.000062 * Math.Sin(A6) +
                              0.000060 * Math.Sin(A7) +
                              0.000056 * Math.Sin(A8) +
                              0.000047 * Math.Sin(A9) +
                              0.000042 * Math.Sin(A10) +
                              0.000040 * Math.Sin(A11) +
                              0.000037 * Math.Sin(A12) +
                              0.000035 * Math.Sin(A13) +
                              0.000023 * Math.Sin(A14);

            JD += DeltaJD2;

            return(JD);
        }