/// <summary> /// /// </summary> /// <param name="startDate">Start Date</param> /// <param name="phase">0, 1/3, 1/2 or 3/4</param> /// <returns></returns> public static DateTime TruePhase(DateTime startDate, MPhase phase) { //What will be the return value double JD = DateTimeUtil.DateTimeToJulian(MeanPhase(startDate, phase)); double ph = 0.0; if (phase == MPhase.FirstQuater) { ph = 0.25; } else if (phase == MPhase.Full) { ph = 0.50; } else if (phase == MPhase.LastQuater) { ph = 0.75; } TimeSpan tp = startDate - NEW_MOON_TIME; double k = tp.TotalDays / MOON_PERIOD; double kint = Math.Floor(k); double kfra = k - kint; if (kfra > ph) { k = kint + 1 + ph; //we already pass that phase, look for the next one } else { k = kint + ph; } //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 = CoordinateTransformation.MapTo0To360Range(2.5534 + 29.10535670 * k - 0.0000014 * T2 - 0.00000011 * T3); M = CoordinateTransformation.DegreesToRadians(M); double Mdash = CoordinateTransformation.MapTo0To360Range(201.5643 + 385.81693528 * k + 0.0107582 * T2 + 0.00001238 * T3 - 0.000000058 * T4); Mdash = CoordinateTransformation.DegreesToRadians(Mdash); double F = CoordinateTransformation.MapTo0To360Range(160.7108 + 390.67050284 * k - 0.0016118 * T2 - 0.00000227 * T3 + 0.00000001 * T4); F = CoordinateTransformation.DegreesToRadians(F); double omega = CoordinateTransformation.MapTo0To360Range(124.7746 - 1.56375588 * k + 0.0020672 * T2 + 0.00000215 * T3); omega = CoordinateTransformation.DegreesToRadians(omega); double A1 = CoordinateTransformation.MapTo0To360Range(299.77 + 0.107408 * k - 0.009173 * T2); A1 = CoordinateTransformation.DegreesToRadians(A1); double A2 = CoordinateTransformation.MapTo0To360Range(251.88 + 0.016321 * k); A2 = CoordinateTransformation.DegreesToRadians(A2); double A3 = CoordinateTransformation.MapTo0To360Range(251.83 + 26.651886 * k); A3 = CoordinateTransformation.DegreesToRadians(A3); double A4 = CoordinateTransformation.MapTo0To360Range(349.42 + 36.412478 * k); A4 = CoordinateTransformation.DegreesToRadians(A4); double A5 = CoordinateTransformation.MapTo0To360Range(84.66 + 18.206239 * k); A5 = CoordinateTransformation.DegreesToRadians(A5); double A6 = CoordinateTransformation.MapTo0To360Range(141.74 + 53.303771 * k); A6 = CoordinateTransformation.DegreesToRadians(A6); double A7 = CoordinateTransformation.MapTo0To360Range(207.14 + 2.453732 * k); A7 = CoordinateTransformation.DegreesToRadians(A7); double A8 = CoordinateTransformation.MapTo0To360Range(154.84 + 7.306860 * k); A8 = CoordinateTransformation.DegreesToRadians(A8); double A9 = CoordinateTransformation.MapTo0To360Range(34.52 + 27.261239 * k); A9 = CoordinateTransformation.DegreesToRadians(A9); double A10 = CoordinateTransformation.MapTo0To360Range(207.19 + 0.121824 * k); A10 = CoordinateTransformation.DegreesToRadians(A10); double A11 = CoordinateTransformation.MapTo0To360Range(291.34 + 1.844379 * k); A11 = CoordinateTransformation.DegreesToRadians(A11); double A12 = CoordinateTransformation.MapTo0To360Range(161.72 + 24.198154 * k); A12 = CoordinateTransformation.DegreesToRadians(A12); double A13 = CoordinateTransformation.MapTo0To360Range(239.56 + 25.513099 * k); A13 = CoordinateTransformation.DegreesToRadians(A13); double A14 = CoordinateTransformation.MapTo0To360Range(331.55 + 3.592518 * k); A14 = CoordinateTransformation.DegreesToRadians(A14); //convert to radians if (phase == MPhase.New) //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 ((phase == MPhase.FirstQuater) || (phase == MPhase.LastQuater)) //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 (phase == MPhase.FirstQuater) //First quarter { JD += W; } else { JD -= W; } } else if (phase == MPhase.Full) //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; } //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(DateTimeUtil.JulianToDateTime(JD)); }
/// <summary> /// get earth ecliptic longitude with a specific Julian date /// </summary> /// <param name="JD"></param> /// <returns></returns> public static double EclipticLongitude(double JD) { double rho = (JD - 2451545) / 365250; double rhosquared = rho * rho; double rhocubed = rhosquared * rho; double rho4 = rhocubed * rho; double rho5 = rho4 * rho; //Calculate L0 int nL0Coefficients = g_L0EarthCoefficients.Length / 3; double L0 = 0; int i; for (i = 0; i < nL0Coefficients; i++) { L0 += g_L0EarthCoefficients[i, 0] * Math.Cos(g_L0EarthCoefficients[i, 1] + g_L0EarthCoefficients[i, 2] * rho); } //Calculate L1 int nL1Coefficients = g_L1EarthCoefficients.Length / 3; double L1 = 0; for (i = 0; i < nL1Coefficients; i++) { L1 += g_L1EarthCoefficients[i, 0] * Math.Cos(g_L1EarthCoefficients[i, 1] + g_L1EarthCoefficients[i, 2] * rho); } //Calculate L2 int nL2Coefficients = g_L2EarthCoefficients.Length / 3; double L2 = 0; for (i = 0; i < nL2Coefficients; i++) { L2 += g_L2EarthCoefficients[i, 0] * Math.Cos(g_L2EarthCoefficients[i, 1] + g_L2EarthCoefficients[i, 2] * rho); } //Calculate L3 int nL3Coefficients = g_L3EarthCoefficients.Length / 3; double L3 = 0; for (i = 0; i < nL3Coefficients; i++) { L3 += g_L3EarthCoefficients[i, 0] * Math.Cos(g_L3EarthCoefficients[i, 1] + g_L3EarthCoefficients[i, 2] * rho); } //Calculate L4 int nL4Coefficients = g_L4EarthCoefficients.Length / 3; double L4 = 0; for (i = 0; i < nL4Coefficients; i++) { L4 += g_L4EarthCoefficients[i, 0] * Math.Cos(g_L4EarthCoefficients[i, 1] + g_L4EarthCoefficients[i, 2] * rho); } //Calculate L5 int nL5Coefficients = g_L5EarthCoefficients.Length / 3; double L5 = 0; for (i = 0; i < nL5Coefficients; i++) { L5 += g_L5EarthCoefficients[i, 0] * Math.Cos(g_L5EarthCoefficients[i, 1] + g_L5EarthCoefficients[i, 2] * rho); } double value = (L0 + L1 * rho + L2 * rhosquared + L3 * rhocubed + L4 * rho4 + L5 * rho5) / 100000000; //convert results back to degrees value = CoordinateTransformation.MapTo0To360Range(CoordinateTransformation.RadiansToDegrees(value)); return(value); }