Esempio n. 1
0
        public static JulianDay Pesach(int Year)
        {
            if (Year < -3761)
            {
                throw new ArgumentOutOfRangeException("Year", "The Hebrew Calendar is not valid prior to 3761 BCE");
            }
            int X     = Year;
            int month = 3;
            int C     = AstroMath.Int(X / 100);
            int S     = AstroMath.Int((C * 3 - 5) / 4);
            int A     = X + 3760;
            int a     = AstroMath.Mod(X * 12 + 12, 19);
            int b     = AstroMath.Mod(X, 4);

            if (X < 1583)
            {
                S = 0;
            }

            double Q = -1.904412361576 + 1.554241796621 * a + 0.25 * b - 0.003177784022 * X + S;
            int    j = AstroMath.Mod(AstroMath.Int(Q) + 3 * X + 5 * b + 2 - S, 7);
            double r = Q - AstroMath.Int(Q);
            int    D;

            if (j == 2 || j == 4 || j == 6)
            {
                D = AstroMath.Int(Q) + 23;
            }
            else if (j == 1 && a > 6 && r >= 0.632870370)
            {
                D = AstroMath.Int(Q) + 24;
            }
            else if (j == 0 && a > 11 && r >= 0.897723765)
            {
                D = AstroMath.Int(Q) + 23;
            }
            else
            {
                D = AstroMath.Int(Q) + 22;
            }

            if (D > 31)
            {
                month = month + 1;
                D     = D - 31;
            }
            /* Debug information */
            Debug.WriteLine("X\t= " + X);
            Debug.WriteLine("C\t= " + C);
            Debug.WriteLine("S\t= " + S);
            Debug.WriteLine("A\t= " + A);
            Debug.WriteLine("a\t= " + a);
            Debug.WriteLine("b\t= " + b);
            Debug.WriteLine("Q\t= " + Q);
            Debug.WriteLine("j\t= " + j);
            Debug.WriteLine("r\t= " + r);
            Debug.WriteLine("D\t= " + D);
            return(new JulianDay(Year, month, D));
        }
Esempio n. 2
0
        public static JulianDay FindPhase(int year, int month, int day, MoonPhases phase)
        {
            var    jd     = new JulianDay(year, month, day);
            double length = 365;

            if (jd.IsLeapYear)
            {
                length = 366;
            }

            double Y = Math.Round(year + ((double)jd.DayOfYear / length), 2);
            double k = ((Y - 2000) * 12.3685);

            switch (phase)
            {
            case MoonPhases.New:
                k = Math.Round(k);
                break;

            case MoonPhases.FirstQuarter:
                if (k < 0)
                {
                    k = Math.Round(k) - 0.25;
                }
                else
                {
                    k = Math.Floor(k) + 0.25;
                }
                break;

            case MoonPhases.Full:
                if (k < 0)
                {
                    k = Math.Round(k) - 0.50;
                }
                else
                {
                    k = Math.Floor(k) + 0.50;
                }
                break;

            case MoonPhases.LastQuarter:
                if (k < 0)
                {
                    k = Math.Round(k) - 0.75;
                }
                else
                {
                    k = Math.Floor(k) + 0.75;
                }
                break;
            }

            Debug.WriteLine("k\t=\t" + Math.Round(k, 2));

            double T  = k / 1236.85;
            double T2 = Math.Pow(T, 2);
            double T3 = Math.Pow(T, 3);
            double T4 = Math.Pow(T, 4);

            Debug.WriteLine("T\t=\t" + Math.Round(T, 5));

            double JDE = 2451550.09766 + 29.530588861 * k
                         + 0.00015437 * T2
                         - 0.000000150 * T3
                         + 0.00000000073 * T4;

            Debug.WriteLine("JDE\t=\t" + Math.Round(JDE, 5));

            //Corrections

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

            double M = 2.5534 + 29.10535670 * k
                       - 0.0000014 * T2
                       - 0.00000011 * T3;

            Debug.Write("M\t=\t" + Math.Round(M, 4));
            M = AstroMath.Mod(M, 360);
            Debug.WriteLine("\t=\t" + Math.Round(M, 4));

            double Mp = 201.5643 + (385.81693528 * k)
                        + (0.0107582 * T2)
                        + (0.00001238 * T3)
                        - (0.000000058 * T4);


            Debug.Write("M′\t=\t" + Math.Round(Mp, 4));
            Mp = AstroMath.Mod(Mp, 360);
            Debug.WriteLine("\t=\t" + Math.Round(Mp, 4));

            double F = 160.7180 + 390.67050284 * k
                       - 0.0016118 * T2
                       - 0.00000227 * T3
                       + 0.000000011 * T4;

            Debug.Write("F\t=\t" + Math.Round(F, 4));
            F = AstroMath.Mod(F, 360);
            Debug.WriteLine("\t=\t" + Math.Round(F, 4));

            double Ω = 124.7746 - (1.56375588 * k)
                       + (0.0020672 * T2)
                       + (0.00000215 * T3);

            Debug.Write("Ω\t=\t" + Math.Round(Ω, 4));
            Ω = AstroMath.Mod(Ω, 360);
            Debug.WriteLine("\t=\t" + Math.Round(Ω, 4));

            double correction = 0;
            //switch (phase)
            //{
            //    case MoonPhases.Full:
            //        correction = FullMoonCorrections(E, M, Mp, F, Ω);
            //        break;
            //}

            //PlanetaryArguments
            double additionalCorrection = 0;

            for (int i = 0; i <= 13; i++)
            {
                IList <double> S = PlanetaryArguments[i];
                additionalCorrection += AdditionalCorrections[i] * AstroMath.Sin(S[0] + (S[1] * k) - (S[2] * T2));
            }

            Debug.WriteLine("Additional Corrections:\t" + Math.Round(additionalCorrection, 5));
            JDE = JDE + correction + additionalCorrection;

            return(new JulianDay(JDE));
        }