public static CAA2DCoordinate Equatorial2Topocentric(double Alpha, double Delta, double Distance, double Longitude, double Latitude, double Height, double JD) { double RhoSinThetaPrime = CAAGlobe.RhoSinThetaPrime(Latitude, Height); double RhoCosThetaPrime = CAAGlobe.RhoCosThetaPrime(Latitude, Height); //Calculate the Sidereal time double theta = CAASidereal.ApparentGreenwichSiderealTime(JD); //Convert to radians Delta = CAACoordinateTransformation.DegreesToRadians(Delta); double cosDelta = Math.Cos(Delta); //Calculate the Parallax double pi = Math.Asin(GlobalMembersStdafx.g_AAParallax_C1 / Distance); double sinpi = Math.Sin(pi); //Calculate the hour angle double H = CAACoordinateTransformation.HoursToRadians(theta - Longitude / 15 - Alpha); double cosH = Math.Cos(H); double sinH = Math.Sin(H); //Calculate the adjustment in right ascension double DeltaAlpha = Math.Atan2(-RhoCosThetaPrime * sinpi * sinH, cosDelta - RhoCosThetaPrime * sinpi * cosH); CAA2DCoordinate Topocentric = new CAA2DCoordinate(); Topocentric.X = CAACoordinateTransformation.MapTo0To24Range(Alpha + CAACoordinateTransformation.RadiansToHours(DeltaAlpha)); Topocentric.Y = CAACoordinateTransformation.RadiansToDegrees(Math.Atan2((Math.Sin(Delta) - RhoSinThetaPrime * sinpi) * Math.Cos(DeltaAlpha), cosDelta - RhoCosThetaPrime * sinpi * cosH)); return(Topocentric); }
public static CAASelenographicMoonDetails CalculateSelenographicPositionOfSun(double JD) { double R = CAAEarth.RadiusVector(JD) * 149597970; double Delta = CAAMoon.RadiusVector(JD); double lambda0 = CAASun.ApparentEclipticLongitude(JD); double lambda = CAAMoon.EclipticLongitude(JD); double beta = CAAMoon.EclipticLatitude(JD); double lambdah = CAACoordinateTransformation.MapTo0To360Range(lambda0 + 180 + Delta / R * 57.296 * Math.Cos(CAACoordinateTransformation.DegreesToRadians(beta)) * Math.Sin(CAACoordinateTransformation.DegreesToRadians(lambda0 - lambda))); double betah = Delta / R * beta; //What will be the return value CAASelenographicMoonDetails details = new CAASelenographicMoonDetails(); //Calculate the optical libration double omega = 0; double DeltaU = 0; double sigma = 0; double I = 0; double rho = 0; double ldash0 = 0; double bdash0 = 0; double ldash20 = 0; double bdash20 = 0; double epsilon = 0; CalculateOpticalLibration(JD, lambdah, betah, ref ldash0, ref bdash0, ref ldash20, ref bdash20, ref epsilon, ref omega, ref DeltaU, ref sigma, ref I, ref rho); details.l0 = ldash0 + ldash20; details.b0 = bdash0 + bdash20; details.c0 = CAACoordinateTransformation.MapTo0To360Range(450 - details.l0); return(details); }
//Conversion functions public static CAA2DCoordinate Equatorial2TopocentricDelta(double Alpha, double Delta, double Distance, double Longitude, double Latitude, double Height, double JD) { double RhoSinThetaPrime = CAAGlobe.RhoSinThetaPrime(Latitude, Height); double RhoCosThetaPrime = CAAGlobe.RhoCosThetaPrime(Latitude, Height); //Calculate the Sidereal time double theta = CAASidereal.ApparentGreenwichSiderealTime(JD); //Convert to radians Delta = CAACoordinateTransformation.DegreesToRadians(Delta); double cosDelta = Math.Cos(Delta); //Calculate the Parallax double pi = Math.Asin(GlobalMembersStdafx.g_AAParallax_C1 / Distance); //Calculate the hour angle double H = CAACoordinateTransformation.HoursToRadians(theta - Longitude / 15 - Alpha); double cosH = Math.Cos(H); double sinH = Math.Sin(H); CAA2DCoordinate DeltaTopocentric = new CAA2DCoordinate(); DeltaTopocentric.X = CAACoordinateTransformation.RadiansToHours(-pi * RhoCosThetaPrime * sinH / cosDelta); DeltaTopocentric.Y = CAACoordinateTransformation.RadiansToDegrees(-pi * (RhoSinThetaPrime * cosDelta - RhoCosThetaPrime * cosH * Math.Sin(Delta))); return(DeltaTopocentric); }
public static double NeptuneLongitudePerihelionJ2000(double JD) { double T = (JD - 2451545.0) / 36525; double Tsquared = T * T; return(CAACoordinateTransformation.MapTo0To360Range(48.120276 + 0.0291866 * T + 0.00007610 * Tsquared)); }
public static double NeptuneInclinationJ2000(double JD) { double T = (JD - 2451545.0) / 36525; double Tsquared = T * T; return(CAACoordinateTransformation.MapTo0To360Range(1.769953 + 0.0002256 * T + 0.00000023 * Tsquared)); }
//////////////////////////////// Implementation /////////////////////////////// protected static void HelperSubroutine(double e, double lambdadash, double p, double a, double omega, double i, double c1, double s1, ref double r, ref double lambda, ref double gamma, ref double w) { double e2 = e * e; double e3 = e2 * e; double e4 = e3 * e; double e5 = e4 * e; double M = CAACoordinateTransformation.DegreesToRadians(lambdadash - p); double Crad = (2 * e - 0.25 * e3 + 0.0520833333 * e5) * Math.Sin(M) + (1.25 * e2 - 0.458333333 * e4) * Math.Sin(2 * M) + (1.083333333 * e3 - 0.671875 * e5) * Math.Sin(3 * M) + 1.072917 * e4 * Math.Sin(4 * M) + 1.142708 * e5 * Math.Sin(5 * M); double C = CAACoordinateTransformation.RadiansToDegrees(Crad); r = a * (1 - e2) / (1 + e * Math.Cos(M + Crad)); double g = omega - 168.8112; double grad = CAACoordinateTransformation.DegreesToRadians(g); double irad = CAACoordinateTransformation.DegreesToRadians(i); double a1 = Math.Sin(irad) * Math.Sin(grad); double a2 = c1 * Math.Sin(irad) * Math.Cos(grad) - s1 * Math.Cos(irad); gamma = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sqrt(a1 * a1 + a2 * a2))); double urad = Math.Atan2(a1, a2); double u = CAACoordinateTransformation.RadiansToDegrees(urad); w = CAACoordinateTransformation.MapTo0To360Range(168.8112 + u); double h = c1 * Math.Sin(irad) - s1 * Math.Cos(irad) * Math.Cos(grad); double psirad = Math.Atan2(s1 * Math.Sin(grad), h); double psi = CAACoordinateTransformation.RadiansToDegrees(psirad); lambda = lambdadash + C + u - g - psi; }
public static double TrueApogee(double k) { double MeanJD = MeanApogee(k); //convert from K to T double T = k / 1325.55; double Tsquared = T * T; double Tcubed = Tsquared * T; double T4 = Tcubed * T; double D = CAACoordinateTransformation.MapTo0To360Range(171.9179 + 335.9106046 * k - 0.0100383 * Tsquared - 0.00001156 * Tcubed + 0.000000055 * T4); D = CAACoordinateTransformation.DegreesToRadians(D); double M = CAACoordinateTransformation.MapTo0To360Range(347.3477 + 27.1577721 * k - 0.0008130 * Tsquared - 0.0000010 * Tcubed); M = CAACoordinateTransformation.DegreesToRadians(M); double F = CAACoordinateTransformation.MapTo0To360Range(316.6109 + 364.5287911 * k - 0.0125053 * Tsquared - 0.0000148 * Tcubed); F = CAACoordinateTransformation.DegreesToRadians(F); int nApogeeCoefficients = GlobalMembersStdafx.g_MoonPerigeeApogeeCoefficients2.Length; double Sigma = 0; for (int i = 0; i < nApogeeCoefficients; i++) { Sigma += (GlobalMembersStdafx.g_MoonPerigeeApogeeCoefficients2[i].C + T * GlobalMembersStdafx.g_MoonPerigeeApogeeCoefficients2[i].T) * Math.Sin(D * GlobalMembersStdafx.g_MoonPerigeeApogeeCoefficients2[i].D + M * GlobalMembersStdafx.g_MoonPerigeeApogeeCoefficients2[i].M + F * GlobalMembersStdafx.g_MoonPerigeeApogeeCoefficients2[i].F); } return(MeanJD + Sigma); }
//Static methods ///////////////////////// Implementation ////////////////////////////////////// public static double Calculate(double JD) { double rho = (JD - 2451545) / 365250; double rhosquared = rho * rho; double rhocubed = rhosquared * rho; double rho4 = rhocubed * rho; double rho5 = rho4 * rho; //Calculate the Suns mean longitude double L0 = CAACoordinateTransformation.MapTo0To360Range(280.4664567 + 360007.6982779 * rho + 0.03032028 * rhosquared + rhocubed / 49931 - rho4 / 15300 - rho5 / 2000000); //Calculate the Suns apparent right ascension double SunLong = CAASun.ApparentEclipticLongitude(JD); double SunLat = CAASun.ApparentEclipticLatitude(JD); double epsilon = CAANutation.TrueObliquityOfEcliptic(JD); CAA2DCoordinate Equatorial = CAACoordinateTransformation.Ecliptic2Equatorial(SunLong, SunLat, epsilon); epsilon = CAACoordinateTransformation.DegreesToRadians(epsilon); double E = L0 - 0.0057183 - Equatorial.X * 15 + CAACoordinateTransformation.DMSToDegrees(0, 0, CAANutation.NutationInLongitude(JD)) * Math.Cos(epsilon); if (E > 180) { E = -(360 - E); } E *= 4; //Convert to minutes of time return(E); }
public static double PerigeeParallax(double k) { //convert from K to T double T = k / 1325.55; double Tsquared = T * T; double Tcubed = Tsquared * T; double T4 = Tcubed * T; double D = CAACoordinateTransformation.MapTo0To360Range(171.9179 + 335.9106046 * k - 0.0100383 * Tsquared - 0.00001156 * Tcubed + 0.000000055 * T4); D = CAACoordinateTransformation.DegreesToRadians(D); double M = CAACoordinateTransformation.MapTo0To360Range(347.3477 + 27.1577721 * k - 0.0008130 * Tsquared - 0.0000010 * Tcubed); M = CAACoordinateTransformation.DegreesToRadians(M); double F = CAACoordinateTransformation.MapTo0To360Range(316.6109 + 364.5287911 * k - 0.0125053 * Tsquared - 0.0000148 * Tcubed); F = CAACoordinateTransformation.DegreesToRadians(F); int nPerigeeCoefficients = GlobalMembersStdafx.g_MoonPerigeeApogeeCoefficients3.Length; double Parallax = 3629.215; for (int i = 0; i < nPerigeeCoefficients; i++) { Parallax += (GlobalMembersStdafx.g_MoonPerigeeApogeeCoefficients3[i].C + T * GlobalMembersStdafx.g_MoonPerigeeApogeeCoefficients3[i].T) * Math.Cos(D * GlobalMembersStdafx.g_MoonPerigeeApogeeCoefficients3[i].D + M * GlobalMembersStdafx.g_MoonPerigeeApogeeCoefficients3[i].M + F * GlobalMembersStdafx.g_MoonPerigeeApogeeCoefficients3[i].F); } return(Parallax / 3600); }
public static double SummerSolstice(int Year) { //calculate the approximate date double JDE = 0; if (Year <= 1000) { double Y = Year / 1000.0; double Ysquared = Y * Y; double Ycubed = Ysquared * Y; double Y4 = Ycubed * Y; JDE = 1721233.25401 + 365241.72562 * Y - 0.05323 * Ysquared + 0.00907 * Ycubed + 0.00025 * Y4; } else { double Y = (Year - 2000) / 1000.0; double Ysquared = Y * Y; double Ycubed = Ysquared * Y; double Y4 = Ycubed * Y; JDE = 2451716.56767 + 365241.62603 * Y + 0.00325 * Ysquared + 0.00888 * Ycubed - 0.00030 * Y4; } double Correction; do { double SunLongitude = CAASun.ApparentEclipticLongitude(JDE); Correction = 58 * Math.Sin(CAACoordinateTransformation.DegreesToRadians(90 - SunLongitude)); JDE += Correction; }while (Math.Abs(Correction) > 0.00001); //Corresponds to an error of 0.86 of a second return(JDE); }
public static double AutumnEquinox(int Year) { //calculate the approximate date double JDE = 0; if (Year <= 1000) { double Y = Year / 1000.0; double Ysquared = Y * Y; double Ycubed = Ysquared * Y; double Y4 = Ycubed * Y; JDE = 1721325.70455 + 365242.49558 * Y - 0.11677 * Ysquared - 0.00297 * Ycubed + 0.00074 * Y4; } else { double Y = (Year - 2000) / 1000.0; double Ysquared = Y * Y; double Ycubed = Ysquared * Y; double Y4 = Ycubed * Y; JDE = 2451810.21715 + 365242.01767 * Y - 0.11575 * Ysquared + 0.00337 * Ycubed + 0.00078 * Y4; } double Correction; do { double SunLongitude = CAASun.ApparentEclipticLongitude(JDE); Correction = 58 * Math.Sin(CAACoordinateTransformation.DegreesToRadians(180 - SunLongitude)); JDE += Correction; }while (Math.Abs(Correction) > 0.00001); //Corresponds to an error of 0.86 of a second return(JDE); }
public static double WinterSolstice(int Year) { //calculate the approximate date double JDE = 0; if (Year <= 1000) { double Y = Year / 1000.0; double Ysquared = Y * Y; double Ycubed = Ysquared * Y; double Y4 = Ycubed * Y; JDE = 1721414.39987 + 365242.88257 * Y - 0.00769 * Ysquared - 0.00933 * Ycubed - 0.00006 * Y4; } else { double Y = (Year - 2000) / 1000.0; double Ysquared = Y * Y; double Ycubed = Ysquared * Y; double Y4 = Ycubed * Y; JDE = 2451900.05952 + 365242.74049 * Y - 0.06223 * Ysquared - 0.00823 * Ycubed + 0.00032 * Y4; } double Correction; do { double SunLongitude = CAASun.ApparentEclipticLongitude(JDE); Correction = 58 * Math.Sin(CAACoordinateTransformation.DegreesToRadians(270 - SunLongitude)); JDE += Correction; }while (Math.Abs(Correction) > 0.00001); //Corresponds to an error of 0.86 of a second return(JDE); }
//Static methods //Tangible Process Only End ////////////////////////////////// Implementation ///////////////////////////// public static CAABinaryStarDetails Calculate(double t, double P, double T, double e, double a, double i, double omega, double w) { double n = 360 / P; double M = CAACoordinateTransformation.MapTo0To360Range(n * (t - T)); double E = CAAKepler.Calculate(M, e); E = CAACoordinateTransformation.DegreesToRadians(E); i = CAACoordinateTransformation.DegreesToRadians(i); w = CAACoordinateTransformation.DegreesToRadians(w); omega = CAACoordinateTransformation.DegreesToRadians(omega); CAABinaryStarDetails details = new CAABinaryStarDetails(); details.r = a * (1 - e * Math.Cos(E)); double v = Math.Atan(Math.Sqrt((1 + e) / (1 - e)) * Math.Tan(E / 2)) * 2; details.Theta = Math.Atan2(Math.Sin(v + w) * Math.Cos(i), Math.Cos(v + w)) + omega; details.Theta = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(details.Theta)); double sinvw = Math.Sin(v + w); double cosvw = Math.Cos(v + w); double cosi = Math.Cos(i); details.Rho = details.r * Math.Sqrt((sinvw * sinvw * cosi * cosi) + (cosvw * cosvw)); return(details); }
//Static methods /////////////////////////////// Implementation //////////////////////////////// public static double MeanGreenwichSiderealTime(double JD) { //Get the Julian day for the same day at midnight int Year = 0; int Month = 0; int Day = 0; int Hour = 0; int Minute = 0; double Second = 0; CAADate date = new CAADate(); date.Set(JD, CAADate.AfterPapalReform(JD)); date.Get(ref Year, ref Month, ref Day, ref Hour, ref Minute, ref Second); date.Set(Year, Month, Day, 0, 0, 0, date.InGregorianCalendar()); double JDMidnight = date.Julian(); //Calculate the sidereal time at midnight double T = (JDMidnight - 2451545) / 36525; double TSquared = T * T; double TCubed = TSquared * T; double Value = 100.46061837 + (36000.770053608 * T) + (0.000387933 * TSquared) - (TCubed / 38710000); //Adjust by the time of day Value += (((Hour * 15) + (Minute * 0.25) + (Second * 0.0041666666666666666666666666666667)) * 1.00273790935); Value = CAACoordinateTransformation.DegreesToHours(Value); return(CAACoordinateTransformation.MapTo0To24Range(Value)); }
//C++ TO C# CONVERTER NOTE: C# does not allow default values for parameters. Overloaded methods are inserted above. //ORIGINAL LINE: static double EarthPerihelion(int k, bool bBarycentric = false) public static double EarthPerihelion(int k, bool bBarycentric) { double kdash = k; double ksquared = kdash * kdash; double JD = 2451547.507 + 365.2596358 * kdash + 0.0000000156 * ksquared; if (!bBarycentric) { //Apply the corrections double A1 = CAACoordinateTransformation.MapTo0To360Range(328.41 + 132.788585 * k); A1 = CAACoordinateTransformation.DegreesToRadians(A1); double A2 = CAACoordinateTransformation.MapTo0To360Range(316.13 + 584.903153 * k); A2 = CAACoordinateTransformation.DegreesToRadians(A2); double A3 = CAACoordinateTransformation.MapTo0To360Range(346.20 + 450.380738 * k); A3 = CAACoordinateTransformation.DegreesToRadians(A3); double A4 = CAACoordinateTransformation.MapTo0To360Range(136.95 + 659.306737 * k); A4 = CAACoordinateTransformation.DegreesToRadians(A4); double A5 = CAACoordinateTransformation.MapTo0To360Range(249.52 + 329.653368 * k); A5 = CAACoordinateTransformation.DegreesToRadians(A5); JD += 1.278 * Math.Sin(A1); JD -= 0.055 * Math.Sin(A2); JD -= 0.091 * Math.Sin(A3); JD -= 0.056 * Math.Sin(A4); JD -= 0.045 * Math.Sin(A5); } return(JD); }
public static double TrueLongitudeAscendingNode(double JD) { double TrueAscendingNode = MeanLongitudeAscendingNode(JD); double D = MeanElongation(JD); D = CAACoordinateTransformation.DegreesToRadians(D); double M = CAAEarth.SunMeanAnomaly(JD); M = CAACoordinateTransformation.DegreesToRadians(M); double Mdash = MeanAnomaly(JD); Mdash = CAACoordinateTransformation.DegreesToRadians(Mdash); double F = ArgumentOfLatitude(JD); F = CAACoordinateTransformation.DegreesToRadians(F); //Add the principal additive terms TrueAscendingNode -= 1.4979 * Math.Sin(2 * (D - F)); TrueAscendingNode -= 0.1500 * Math.Sin(M); TrueAscendingNode -= 0.1226 * Math.Sin(2 * D); TrueAscendingNode += 0.1176 * Math.Sin(2 * F); TrueAscendingNode -= 0.0801 * Math.Sin(2 * (Mdash - F)); return(CAACoordinateTransformation.MapTo0To360Range(TrueAscendingNode)); }
public static CAAEclipticalElementDetails FK4B1950ToFK5J2000(double i0, double w0, double omega0) { //convert to radians double L = CAACoordinateTransformation.DegreesToRadians(5.19856209); double J = CAACoordinateTransformation.DegreesToRadians(0.00651966); double i0rad = CAACoordinateTransformation.DegreesToRadians(i0); double omega0rad = CAACoordinateTransformation.DegreesToRadians(omega0); double sini0rad = Math.Sin(i0rad); double cosi0rad = Math.Cos(i0rad); //Calculate some values used later double cosJ = Math.Cos(J); double sinJ = Math.Sin(J); double W = L + omega0rad; double cosW = Math.Cos(W); double sinW = Math.Sin(W); double A = sinJ * sinW; double B = sini0rad * cosJ + cosi0rad * sinJ * cosW; //Calculate the values CAAEclipticalElementDetails details = new CAAEclipticalElementDetails(); details.i = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sqrt(A * A + B * B))); double cosi = cosi0rad * cosJ - sini0rad * sinJ * cosW; if (cosi < 0) { details.i = 180 - details.i; } details.w = CAACoordinateTransformation.MapTo0To360Range(w0 + CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(A, B))); details.omega = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(sini0rad * sinW, cosi0rad * sinJ + sini0rad * cosJ * cosW)) - 4.50001688); return(details); }
public static double PassageThroNode(double k) { //convert from K to T double T = k / 1342.23; double Tsquared = T * T; double Tcubed = Tsquared * T; double T4 = Tcubed * T; double D = CAACoordinateTransformation.MapTo0To360Range(183.6380 + 331.73735682 * k + 0.0014852 * Tsquared + 0.00000209 * Tcubed - 0.000000010 * T4); double M = CAACoordinateTransformation.MapTo0To360Range(17.4006 + 26.82037250 * k + 0.0001186 * Tsquared + 0.00000006 * Tcubed); double Mdash = CAACoordinateTransformation.MapTo0To360Range(38.3776 + 355.52747313 * k + 0.0123499 * Tsquared + 0.000014627 * Tcubed - 0.000000069 * T4); double omega = CAACoordinateTransformation.MapTo0To360Range(123.9767 - 1.44098956 * k + 0.0020608 * Tsquared + 0.00000214 * Tcubed - 0.000000016 * T4); double V = CAACoordinateTransformation.MapTo0To360Range(299.75 + 132.85 * T - 0.009173 * Tsquared); double P = CAACoordinateTransformation.MapTo0To360Range(omega + 272.75 - 2.3 * T); double E = 1 - 0.002516 * T - 0.0000074 * Tsquared; //convert to radians D = CAACoordinateTransformation.DegreesToRadians(D); double D2 = 2 * D; double D4 = D2 * D2; M = CAACoordinateTransformation.DegreesToRadians(M); Mdash = CAACoordinateTransformation.DegreesToRadians(Mdash); double Mdash2 = 2 * Mdash; omega = CAACoordinateTransformation.DegreesToRadians(omega); V = CAACoordinateTransformation.DegreesToRadians(V); P = CAACoordinateTransformation.DegreesToRadians(P); double JD = 2451565.1619 + 27.212220817 * k + 0.0002762 * Tsquared + 0.000000021 * Tcubed - 0.000000000088 * T4 - 0.4721 * Math.Sin(Mdash) - 0.1649 * Math.Sin(D2) - 0.0868 * Math.Sin(D2 - Mdash) + 0.0084 * Math.Sin(D2 + Mdash) - E * 0.0083 * Math.Sin(D2 - M) - E * 0.0039 * Math.Sin(D2 - M - Mdash) + 0.0034 * Math.Sin(Mdash2) - 0.0031 * Math.Sin(D2 - Mdash2) + E * 0.0030 * Math.Sin(D2 + M) + E * 0.0028 * Math.Sin(M - Mdash) + E * 0.0026 * Math.Sin(M) + 0.0025 * Math.Sin(D4) + 0.0024 * Math.Sin(D) + E * 0.0022 * Math.Sin(M + Mdash) + 0.0017 * Math.Sin(omega) + 0.0014 * Math.Sin(D4 - Mdash) + E * 0.0005 * Math.Sin(D2 + M - Mdash) + E * 0.0004 * Math.Sin(D2 - M + Mdash) - E * 0.0003 * Math.Sin(D2 - M * M) + E * 0.0003 * Math.Sin(D4 - M) + 0.0003 * Math.Sin(V) + 0.0003 * Math.Sin(P); return(JD); }
//Static methods ///////////////////////////// Implementation ////////////////////////////////// public static double EclipticLongitude(double JD) { double rho = (JD - 2451545) / 365250; double rhosquared = rho * rho; double rhocubed = rhosquared * rho; double rho4 = rhocubed * rho; //Calculate L0 int nL0Coefficients = GlobalMembersStdafx.g_L0NeptuneCoefficients.Length; double L0 = 0; int i; for (i = 0; i < nL0Coefficients; i++) { L0 += GlobalMembersStdafx.g_L0NeptuneCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_L0NeptuneCoefficients[i].B + GlobalMembersStdafx.g_L0NeptuneCoefficients[i].C * rho); } //Calculate L1 int nL1Coefficients = GlobalMembersStdafx.g_L1NeptuneCoefficients.Length; double L1 = 0; for (i = 0; i < nL1Coefficients; i++) { L1 += GlobalMembersStdafx.g_L1NeptuneCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_L1NeptuneCoefficients[i].B + GlobalMembersStdafx.g_L1NeptuneCoefficients[i].C * rho); } //Calculate L2 int nL2Coefficients = GlobalMembersStdafx.g_L2NeptuneCoefficients.Length; double L2 = 0; for (i = 0; i < nL2Coefficients; i++) { L2 += GlobalMembersStdafx.g_L2NeptuneCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_L2NeptuneCoefficients[i].B + GlobalMembersStdafx.g_L2NeptuneCoefficients[i].C * rho); } //Calculate L3 int nL3Coefficients = GlobalMembersStdafx.g_L3NeptuneCoefficients.Length; double L3 = 0; for (i = 0; i < nL3Coefficients; i++) { L3 += GlobalMembersStdafx.g_L3NeptuneCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_L3NeptuneCoefficients[i].B + GlobalMembersStdafx.g_L3NeptuneCoefficients[i].C * rho); } //Calculate L4 int nL4Coefficients = GlobalMembersStdafx.g_L4NeptuneCoefficients.Length; double L4 = 0; for (i = 0; i < nL4Coefficients; i++) { L4 += GlobalMembersStdafx.g_L4NeptuneCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_L4NeptuneCoefficients[i].B + GlobalMembersStdafx.g_L4NeptuneCoefficients[i].C * rho); } double @value = (L0 + L1 * rho + L2 * rhosquared + L3 * rhocubed + L4 * rho4) / 100000000; //convert results back to degrees @value = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(@value)); return(@value); }
public static double DistanceBetweenPoints(double GeographicalLatitude1, double GeographicalLongitude1, double GeographicalLatitude2, double GeographicalLongitude2) { //Convert from degress to radians GeographicalLatitude1 = CAACoordinateTransformation.DegreesToRadians(GeographicalLatitude1); GeographicalLatitude2 = CAACoordinateTransformation.DegreesToRadians(GeographicalLatitude2); GeographicalLongitude1 = CAACoordinateTransformation.DegreesToRadians(GeographicalLongitude1); GeographicalLongitude2 = CAACoordinateTransformation.DegreesToRadians(GeographicalLongitude2); double F = (GeographicalLatitude1 + GeographicalLatitude2) / 2; double G = (GeographicalLatitude1 - GeographicalLatitude2) / 2; double lambda = (GeographicalLongitude1 - GeographicalLongitude2) / 2; double sinG = Math.Sin(G); double cosG = Math.Cos(G); double cosF = Math.Cos(F); double sinF = Math.Sin(F); double sinLambda = Math.Sin(lambda); double cosLambda = Math.Cos(lambda); double S = (sinG * sinG * cosLambda * cosLambda) + (cosF * cosF * sinLambda * sinLambda); double C = (cosG * cosG * cosLambda * cosLambda) + (sinF * sinF * sinLambda * sinLambda); double w = Math.Atan(Math.Sqrt(S / C)); double R = Math.Sqrt(S * C) / w; double D = 2 * w * 6378.14; double Hprime = (3 * R - 1) / (2 * C); double Hprime2 = (3 * R + 1) / (2 * S); double f = 0.0033528131778969144060323814696721; return(D * (1 + (f * Hprime * sinF * sinF * cosG * cosG) - (f * Hprime2 * cosF * cosF * sinG * sinG))); }
//Static methods //////////////////////////////// Implementation /////////////////////////////// public static double SpringEquinox(int Year) { //calculate the approximate date double JDE = 0; if (Year <= 1000) { double Y = Year / 1000.0; double Ysquared = Y * Y; double Ycubed = Ysquared * Y; double Y4 = Ycubed * Y; JDE = 1721139.29189 + 365242.13740 * Y + 0.06134 * Ysquared + 0.00111 * Ycubed - 0.00071 * Y4; } else { double Y = (Year - 2000) / 1000.0; double Ysquared = Y * Y; double Ycubed = Ysquared * Y; double Y4 = Ycubed * Y; JDE = 2451623.80984 + 365242.37404 * Y + 0.05169 * Ysquared - 0.00411 * Ycubed - 0.00057 * Y4; } double Correction; do { double SunLongitude = CAASun.ApparentEclipticLongitude(JDE); Correction = 58 * Math.Sin(CAACoordinateTransformation.DegreesToRadians(-SunLongitude)); JDE += Correction; }while (Math.Abs(Correction) > 0.00001); //Corresponds to an error of 0.86 of a second return(JDE); }
public static double EclipticLongitude(double JD) { double Ldash = MeanLongitude(JD); double LdashDegrees = Ldash; Ldash = CAACoordinateTransformation.DegreesToRadians(Ldash); double D = MeanElongation(JD); D = CAACoordinateTransformation.DegreesToRadians(D); double M = CAAEarth.SunMeanAnomaly(JD); M = CAACoordinateTransformation.DegreesToRadians(M); double Mdash = MeanAnomaly(JD); Mdash = CAACoordinateTransformation.DegreesToRadians(Mdash); double F = ArgumentOfLatitude(JD); F = CAACoordinateTransformation.DegreesToRadians(F); double E = CAAEarth.Eccentricity(JD); double T = (JD - 2451545) / 36525; double A1 = CAACoordinateTransformation.MapTo0To360Range(119.75 + 131.849 * T); A1 = CAACoordinateTransformation.DegreesToRadians(A1); double A2 = CAACoordinateTransformation.MapTo0To360Range(53.09 + 479264.290 * T); A2 = CAACoordinateTransformation.DegreesToRadians(A2); double A3 = CAACoordinateTransformation.MapTo0To360Range(313.45 + 481266.484 * T); A3 = CAACoordinateTransformation.DegreesToRadians(A3); int nLCoefficients = GlobalMembersStdafx.g_MoonCoefficients1.Length; Debug.Assert(GlobalMembersStdafx.g_MoonCoefficients2.Length == nLCoefficients); double SigmaL = 0; for (int i = 0; i < nLCoefficients; i++) { double ThisSigma = GlobalMembersStdafx.g_MoonCoefficients2[i].A * Math.Sin(GlobalMembersStdafx.g_MoonCoefficients1[i].D * D + GlobalMembersStdafx.g_MoonCoefficients1[i].M * M + GlobalMembersStdafx.g_MoonCoefficients1[i].Mdash * Mdash + GlobalMembersStdafx.g_MoonCoefficients1[i].F * F); if (GlobalMembersStdafx.g_MoonCoefficients1[i].M != 0) { ThisSigma *= E; } SigmaL += ThisSigma; } //Finally the additive terms SigmaL += 3958 * Math.Sin(A1); SigmaL += 1962 * Math.Sin(Ldash - F); SigmaL += 318 * Math.Sin(A2); //And finally apply the nutation in longitude double NutationInLong = CAANutation.NutationInLongitude(JD); return(CAACoordinateTransformation.MapTo0To360Range(LdashDegrees + SigmaL / 1000000 + NutationInLong / 3600)); }
public static double EclipticLatitude(double JD) { double rho = (JD - 2451545) / 365250; double rhosquared = rho * rho; double rhocubed = rhosquared * rho; double rho4 = rhocubed * rho; //Calculate B0 int nB0Coefficients = GlobalMembersStdafx.g_B0MarsCoefficients.Length; double B0 = 0; int i; for (i = 0; i < nB0Coefficients; i++) { B0 += GlobalMembersStdafx.g_B0MarsCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_B0MarsCoefficients[i].B + GlobalMembersStdafx.g_B0MarsCoefficients[i].C * rho); } //Calculate B1 int nB1Coefficients = GlobalMembersStdafx.g_B1MarsCoefficients.Length; double B1 = 0; for (i = 0; i < nB1Coefficients; i++) { B1 += GlobalMembersStdafx.g_B1MarsCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_B1MarsCoefficients[i].B + GlobalMembersStdafx.g_B1MarsCoefficients[i].C * rho); } //Calculate B2 int nB2Coefficients = GlobalMembersStdafx.g_B2MarsCoefficients.Length; double B2 = 0; for (i = 0; i < nB2Coefficients; i++) { B2 += GlobalMembersStdafx.g_B2MarsCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_B2MarsCoefficients[i].B + GlobalMembersStdafx.g_B2MarsCoefficients[i].C * rho); } //Calculate B3 int nB3Coefficients = GlobalMembersStdafx.g_B3MarsCoefficients.Length; double B3 = 0; for (i = 0; i < nB3Coefficients; i++) { B3 += GlobalMembersStdafx.g_B3MarsCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_B3MarsCoefficients[i].B + GlobalMembersStdafx.g_B3MarsCoefficients[i].C * rho); } //Calculate B4 int nB4Coefficients = GlobalMembersStdafx.g_B4MarsCoefficients.Length; double B4 = 0; for (i = 0; i < nB4Coefficients; i++) { B4 += GlobalMembersStdafx.g_B4MarsCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_B4MarsCoefficients[i].B + GlobalMembersStdafx.g_B4MarsCoefficients[i].C * rho); } double @value = (B0 + B1 * rho + B2 * rhosquared + B3 * rhocubed + B4 * rho4) / 100000000; //convert results back to degrees @value = CAACoordinateTransformation.RadiansToDegrees(@value); return(@value); }
//C++ TO C# CONVERTER NOTE: C# does not allow default values for parameters. Overloaded methods are inserted above. //ORIGINAL LINE: static double RefractionFromApparent(double Altitude, double Pressure = 1010, double Temperature = 10) public static double RefractionFromApparent(double Altitude, double Pressure, double Temperature) { double @value = 1 / (Math.Tan(CAACoordinateTransformation.DegreesToRadians(Altitude + 7.31 / (Altitude + 4.4)))) + 0.0013515; @value *= (Pressure / 1010 * 283 / (273 + Temperature)); @value /= 60; return(@value); }
//C++ TO C# CONVERTER NOTE: C# does not allow default values for parameters. Overloaded methods are inserted above. //ORIGINAL LINE: static double RefractionFromTrue(double Altitude, double Pressure = 1010, double Temperature = 10) public static double RefractionFromTrue(double Altitude, double Pressure, double Temperature) { double @value = 1.02 / (Math.Tan(CAACoordinateTransformation.DegreesToRadians(Altitude + 10.3 / (Altitude + 5.11)))) + 0.0019279; @value *= (Pressure / 1010 * 283 / (273 + Temperature)); @value /= 60; return(@value); }
//Static methods ////////////////////// Implementation ///////////////////////////////////////// public static double ParallacticAngle(double HourAngle, double Latitude, double delta) { HourAngle = CAACoordinateTransformation.HoursToRadians(HourAngle); Latitude = CAACoordinateTransformation.DegreesToRadians(Latitude); delta = CAACoordinateTransformation.DegreesToRadians(delta); return(CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(Math.Sin(HourAngle), Math.Tan(Latitude) * Math.Cos(delta) - Math.Sin(delta) * Math.Cos(HourAngle)))); }
public static double SaturnMagnitudeAA(double r, double Delta, double DeltaU, double B) { //Convert from degrees to radians B = CAACoordinateTransformation.DegreesToRadians(B); double sinB = Math.Sin(B); return(-8.88 + 5 * Math.Log10(r * Delta) + 0.044 * Math.Abs(DeltaU) - 2.60 * Math.Sin(Math.Abs(B)) + 1.25 * sinB * sinB); }
//Static methods /////////////////////////// Implementation //////////////////////////////////// public static double RhoSinThetaPrime(double GeographicalLatitude, double Height) { GeographicalLatitude = CAACoordinateTransformation.DegreesToRadians(GeographicalLatitude); double U = Math.Atan(0.99664719 * Math.Tan(GeographicalLatitude)); return(0.99664719 * Math.Sin(U) + (Height / 6378149 * Math.Sin(GeographicalLatitude))); }
public static double IlluminatedFraction(double PhaseAngle) { //Convert from degrees to radians PhaseAngle = CAACoordinateTransformation.DegreesToRadians(PhaseAngle); //Return the result return((1 + Math.Cos(PhaseAngle)) / 2); }
public static double PhaseAngle(double GeocentricElongation, double EarthObjectDistance, double EarthSunDistance) { //Convert from degrees to radians GeocentricElongation = CAACoordinateTransformation.DegreesToRadians(GeocentricElongation); //Return the result return(CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(EarthSunDistance * Math.Sin(GeocentricElongation), EarthObjectDistance - EarthSunDistance * Math.Cos(GeocentricElongation))))); }