//C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: void Get(int& Year, int& Month, int& Day, int& Hour, int& Minute, double& Second) const public void Get(ref int Year, ref int Month, ref int Day, ref int Hour, ref int Minute, ref double Second) { double JD = m_dblJulian + 0.5; double tempZ = 0; double F = GlobalMembersStdafx.modf(JD, ref tempZ); int Z = (int)(tempZ); int A; if (m_bGregorianCalendar) //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 { int alpha = (int)((Z - 1867216.25) / 36524.25); A = Z + 1 + alpha - (int)((int)alpha / 4.0); } else { A = Z; } int B = A + 1524; int C = (int)((B - 122.1) / 365.25); int D = (int)(365.25 * C); int E = (int)((B - D) / 30.6001); double dblDay = B - D - (int)(30.6001 * E) + F; Day = (int)(dblDay); if (E < 14) { Month = E - 1; } else { Month = E - 13; } if (Month > 2) { Year = C - 4716; } else { Year = C - 4715; } F = GlobalMembersStdafx.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; }
//Static methods public static CAASolarEclipseDetails CalculateSolar(double k) { #if _DEBUG double intp = 0; bool bSolarEclipse = (GlobalMembersStdafx.modf(k, ref intp) == 0); Debug.Assert(bSolarEclipse); #endif double Mdash = 0; return(Calculate(k, ref Mdash)); }
public static CAALunarEclipseDetails CalculateLunar(double k) { #if _DEBUG double intp = 0; bool bSolarEclipse = (GlobalMembersStdafx.modf(k, ref intp) == 0); Debug.Assert(!bSolarEclipse); #endif double Mdash = 0; CAASolarEclipseDetails solarDetails = Calculate(k, ref Mdash); //What will be the return value CAALunarEclipseDetails details = new CAALunarEclipseDetails(); details.bEclipse = solarDetails.bEclipse; details.F = solarDetails.F; details.gamma = solarDetails.gamma; details.TimeOfMaximumEclipse = solarDetails.TimeOfMaximumEclipse; details.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); }
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 = CAACoordinateTransformation.MapTo0To360Range(2.5534 + 29.10535670 * k - 0.0000014 * T2 - 0.00000011 * T3); M = CAACoordinateTransformation.DegreesToRadians(M); double Mdash = CAACoordinateTransformation.MapTo0To360Range(201.5643 + 385.81693528 * k + 0.0107582 * T2 + 0.00001238 * T3 - 0.000000058 * T4); Mdash = CAACoordinateTransformation.DegreesToRadians(Mdash); double F = CAACoordinateTransformation.MapTo0To360Range(160.7108 + 390.67050284 * k - 0.0016118 * T2 - 0.00000227 * T3 + 0.00000001 * T4); F = CAACoordinateTransformation.DegreesToRadians(F); double omega = CAACoordinateTransformation.MapTo0To360Range(124.7746 - 1.56375588 * k + 0.0020672 * T2 + 0.00000215 * T3); omega = CAACoordinateTransformation.DegreesToRadians(omega); double A1 = CAACoordinateTransformation.MapTo0To360Range(299.77 + 0.107408 * k - 0.009173 * T2); A1 = CAACoordinateTransformation.DegreesToRadians(A1); double A2 = CAACoordinateTransformation.MapTo0To360Range(251.88 + 0.016321 * k); A2 = CAACoordinateTransformation.DegreesToRadians(A2); double A3 = CAACoordinateTransformation.MapTo0To360Range(251.83 + 26.651886 * k); A3 = CAACoordinateTransformation.DegreesToRadians(A3); double A4 = CAACoordinateTransformation.MapTo0To360Range(349.42 + 36.412478 * k); A4 = CAACoordinateTransformation.DegreesToRadians(A4); double A5 = CAACoordinateTransformation.MapTo0To360Range(84.66 + 18.206239 * k); A5 = CAACoordinateTransformation.DegreesToRadians(A5); double A6 = CAACoordinateTransformation.MapTo0To360Range(141.74 + 53.303771 * k); A6 = CAACoordinateTransformation.DegreesToRadians(A6); double A7 = CAACoordinateTransformation.MapTo0To360Range(207.14 + 2.453732 * k); A7 = CAACoordinateTransformation.DegreesToRadians(A7); double A8 = CAACoordinateTransformation.MapTo0To360Range(154.84 + 7.306860 * k); A8 = CAACoordinateTransformation.DegreesToRadians(A8); double A9 = CAACoordinateTransformation.MapTo0To360Range(34.52 + 27.261239 * k); A9 = CAACoordinateTransformation.DegreesToRadians(A9); double A10 = CAACoordinateTransformation.MapTo0To360Range(207.19 + 0.121824 * k); A10 = CAACoordinateTransformation.DegreesToRadians(A10); double A11 = CAACoordinateTransformation.MapTo0To360Range(291.34 + 1.844379 * k); A11 = CAACoordinateTransformation.DegreesToRadians(A11); double A12 = CAACoordinateTransformation.MapTo0To360Range(161.72 + 24.198154 * k); A12 = CAACoordinateTransformation.DegreesToRadians(A12); double A13 = CAACoordinateTransformation.MapTo0To360Range(239.56 + 25.513099 * k); A13 = CAACoordinateTransformation.DegreesToRadians(A13); double A14 = CAACoordinateTransformation.MapTo0To360Range(331.55 + 3.592518 * k); A14 = CAACoordinateTransformation.DegreesToRadians(A14); //convert to radians double kint = 0; double kfrac = GlobalMembersStdafx.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 { Debug.Assert(false); } //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); }
//Tangible Process Only End //////////////////////////// Implementation /////////////////////////////////// protected static CAASolarEclipseDetails Calculate(double k, ref double Mdash) { //Are we looking for a solar or lunar eclipse double intp = 0; bool bSolarEclipse = (GlobalMembersStdafx.modf(k, ref intp) == 0); //What will be the return value CAASolarEclipseDetails details = new CAASolarEclipseDetails(); //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 = CAACoordinateTransformation.MapTo0To360Range(2.5534 + 29.10535670 * k - 0.0000014 * T2 - 0.00000011 * T3); M = CAACoordinateTransformation.DegreesToRadians(M); Mdash = CAACoordinateTransformation.MapTo0To360Range(201.5643 + 385.81693528 * k + 0.0107582 * T2 + 0.00001238 * T3 - 0.000000058 * T4); Mdash = CAACoordinateTransformation.DegreesToRadians(Mdash); double omega = CAACoordinateTransformation.MapTo0To360Range(124.7746 - 1.56375588 * k + 0.0020672 * T2 + 0.00000215 * T3); omega = CAACoordinateTransformation.DegreesToRadians(omega); double F = CAACoordinateTransformation.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 = CAACoordinateTransformation.DegreesToRadians(F); Fdash = CAACoordinateTransformation.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 = CAACoordinateTransformation.MapTo0To360Range(299.77 + 0.107408 * k - 0.009173 * T2); A1 = CAACoordinateTransformation.DegreesToRadians(A1); details.TimeOfMaximumEclipse = CAAMoonPhases.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); }