/// <summary> /// Gets longitude of ascending node of Lunar orbit for given instant. /// </summary> /// <param name="jd">Julian Day</param> /// <param name="trueAscendingNode">True if position of true ascending node is needed, false for mean position</param> /// <returns>Longitude of ascending node of Lunar orbit, in degrees.</returns> private static double AscendingNode(double jd, bool trueAscendingNode) { double T = (jd - 2451545.0) / 36525.0; double T2 = T * T; double T3 = T2 * T; double T4 = T3 * T; double Omega = 125.0445479 - 1934.1362891 * T + 0.0020754 * T2 + T3 / 467441.0 - T4 / 60616000.0; if (trueAscendingNode) { // Mean elongation of the Moon double D = 297.8501921 + 445267.1114034 * T - 0.0018819 * T2 + T3 / 545868.0 - T4 / 113065000.0; // Sun's mean anomaly double M = 357.5291092 + 35999.0502909 * T - 0.0001536 * T2 + T3 / 24490000.0; // Moon's mean anomaly double M_ = 134.9633964 + 477198.8675055 * T + 0.0087414 * T2 + T3 / 69699.0 - T4 / 14712000.0; // Moon's argument of latitude (mean dinstance of the Moon from its ascending node) double F = 93.2720950 + 483202.0175233 * T - 0.0036539 * T2 - T3 / 3526000.0 + T4 / 863310000.0; Omega += -1.4979 * Math.Sin(Angle.ToRadians(2 * (D - F))) - 0.1500 * Math.Sin(Angle.ToRadians(M)) - 0.1226 * Math.Sin(Angle.ToRadians(2 * D)) + 0.1176 * Math.Sin(Angle.ToRadians(2 * F)) - 0.0801 * Math.Sin(Angle.ToRadians(2 * (M_ - F))); } return(Angle.To360(Omega)); }
/// <summary> /// Calculates aberration elements for given instant. /// </summary> /// <param name="jde">Julian Ephemeris Day, corresponding to the given instant.</param> /// <returns>Aberration elements for the given instant.</returns> /// <remarks> /// AA(II), pp. 151, 163, 164 /// </remarks> public static AberrationElements AberrationElements(double jde) { double T = (jde - 2451545.0) / 36525.0; double T2 = T * T; double e = 0.016708634 - 0.000042037 * T - 0.0000001267 * T2; double pi = 102.93735 + 1.71946 * T + 0.00046 * T2; // geometric true longitude of the Sun double L0 = 280.46646 + 36000.76983 * T + 0.0003032 * T2; // mean anomaly of the Sun double M = 357.52911 + 35999.05029 * T - 0.0001537 * T2; M = Angle.ToRadians(M); // Sun's equation of the center double C = (1.914602 - 0.004817 * T - 0.000014 * T2) * Math.Sin(M) + (0.019993 - 0.000101 * T) * Math.Sin(2 * M) + 0.000289 * Math.Sin(3 * M); return(new AberrationElements() { e = e, pi = pi, lambda = Angle.To360(L0 + C) }); }
/// <summary> /// Performs reduction of equatorial coordinates from one epoch to another /// with using of precessional elements. /// </summary> /// <param name="eq0">Equatorial coordinates for initial epoch.</param> /// <param name="p">Precessional elements for reduction from initial epoch to target (final) epoch.</param> /// <returns>Equatorial coordinates for target (final) epoch.</returns> /// <remarks> /// This method is taken from AA(I), formula 20.4. /// </remarks> public static CrdsEquatorial GetEquatorialCoordinates(CrdsEquatorial eq0, PrecessionalElements p) { CrdsEquatorial eq = new CrdsEquatorial(); double sinDelta0 = Math.Sin(Angle.ToRadians(eq0.Delta)); double cosDelta0 = Math.Cos(Angle.ToRadians(eq0.Delta)); double sinTheta = Math.Sin(Angle.ToRadians(p.theta)); double cosTheta = Math.Cos(Angle.ToRadians(p.theta)); double sinAlpha0Zeta = Math.Sin(Angle.ToRadians(eq0.Alpha + p.zeta)); double cosAlpha0Zeta = Math.Cos(Angle.ToRadians(eq0.Alpha + p.zeta)); double A = cosDelta0 * sinAlpha0Zeta; double B = cosTheta * cosDelta0 * cosAlpha0Zeta - sinTheta * sinDelta0; double C = sinTheta * cosDelta0 * cosAlpha0Zeta + cosTheta * sinDelta0; eq.Alpha = Angle.ToDegrees(Math.Atan2(A, B)) + p.z; eq.Alpha = Angle.To360(eq.Alpha); if (Math.Abs(C) == 1) { eq.Delta = Angle.ToDegrees(Math.Acos(A * A + B * B)); } else { eq.Delta = Angle.ToDegrees(Math.Asin(C)); } return(eq); }
/// <summary> /// Converts rectangular topocentric coordinates of a planet to topocentrical ecliptical coordinates /// </summary> /// <param name="rect">Rectangular topocentric coordinates of a planet</param> /// <returns>Topocentrical ecliptical coordinates of a planet</returns> public static CrdsEcliptical ToEcliptical(this CrdsRectangular rect) { double lambda = Angle.To360(Angle.ToDegrees(Math.Atan2(rect.Y, rect.X))); double beta = Angle.ToDegrees(Math.Atan(rect.Z / Math.Sqrt(rect.X * rect.X + rect.Y * rect.Y))); double distance = Math.Sqrt(rect.X * rect.X + rect.Y * rect.Y + rect.Z * rect.Z); return(new CrdsEcliptical(lambda, beta, distance)); }
/// <summary> /// Adds corrections to equatorial coordinates /// </summary> public static CrdsEquatorial operator +(CrdsEquatorial lhs, CrdsEquatorial rhs) { CrdsEquatorial eq = new CrdsEquatorial(); eq.Alpha = Angle.To360(lhs.Alpha + rhs.Alpha); eq.Delta = lhs.Delta + rhs.Delta; return(eq); }
/// <summary> /// Adds corrections to ecliptical coordinates /// </summary> public static CrdsEcliptical operator +(CrdsEcliptical lhs, CrdsEcliptical rhs) { CrdsEcliptical ecl = new CrdsEcliptical(); ecl.Lambda = Angle.To360(lhs.Lambda + rhs.Lambda); ecl.Beta = lhs.Beta + rhs.Beta; ecl.Distance = lhs.Distance; return(ecl); }
public static CrdsHeliocentrical operator+(CrdsHeliocentrical lhs, CrdsHeliocentrical rhs) { return(new CrdsHeliocentrical() { L = Angle.To360(lhs.L + rhs.L), B = lhs.B + rhs.B, R = lhs.R + rhs.R, }); }
/// <summary> /// Calculates visible appearance of planet for given date. /// </summary> /// <param name="jd">Julian day</param> /// <param name="planet">Planet number to calculate appearance, 1 = Mercury, 2 = Venus and etc.</param> /// <param name="eq">Equatorial coordinates of the planet</param> /// <param name="distance">Distance from the planet to the Earth</param> /// <returns>Appearance parameters of the planet</returns> /// <remarks> /// This method is based on book "Practical Ephemeris Calculations", Montenbruck. /// See topic 6.4, pp. 88-92. /// </remarks> public static PlanetAppearance PlanetAppearance(double jd, int planet, CrdsEquatorial eq, double distance) { PlanetAppearance a = new PlanetAppearance(); double d = jd - 2451545.0; double T = d / 36525.0; // coordinates of the point to which the north pole of the planet is pointing. CrdsEquatorial eq0 = new CrdsEquatorial(); eq0.Alpha = Angle.To360(cAlpha0[planet - 1][0] + cAlpha0[planet - 1][1] * T + cAlpha0[planet - 1][2] * T); eq0.Delta = cDelta0[planet - 1][0] + cDelta0[planet - 1][1] * T + cDelta0[planet - 1][2] * T; // take light time effect into account d -= PlanetPositions.LightTimeEffect(distance); T = d / 36525.0; // position of null meridian double W = Angle.To360(cW[planet - 1][0] + cW[planet - 1][1] * d + cW[planet - 1][2] * T); double delta = Angle.ToRadians(eq.Delta); double alpha = Angle.ToRadians(eq.Alpha); double delta0 = Angle.ToRadians(eq0.Delta); double dAlpha0 = Angle.ToRadians(eq0.Alpha - eq.Alpha); double sinD = -Math.Sin(delta0) * Math.Sin(delta) - Math.Cos(delta0) * Math.Cos(delta) * Math.Cos(dAlpha0); // planetographic latitude of the Earth a.D = Angle.ToDegrees(Math.Asin(sinD)); double cosD = Math.Cos(Angle.ToRadians(a.D)); double sinP = Math.Cos(delta0) * Math.Sin(dAlpha0) / cosD; double cosP = (Math.Sin(delta0) * Math.Cos(delta) - Math.Cos(delta0) * Math.Sin(delta) * Math.Cos(dAlpha0)) / cosD; // position angle of the axis a.P = Angle.To360(Angle.ToDegrees(Math.Atan2(sinP, cosP))); double sinK = (-Math.Cos(delta0) * Math.Sin(delta) + Math.Sin(delta0) * Math.Cos(delta) * Math.Cos(dAlpha0)) / cosD; double cosK = Math.Cos(delta) * Math.Sin(dAlpha0) / cosD; double K = Angle.ToDegrees(Math.Atan2(sinK, cosK)); // planetographic longitude of the central meridian a.CM = planet == 5 ? JupiterCM2(jd) : Angle.To360(Math.Sign(W) * (W - K)); return(a); }
/// <summary> /// Calculates mean sidereal time at Greenwich for given instant. /// </summary> /// <param name="jd">Julian Day</param> /// <returns>Mean sidereal time at Greenwich, expressed in degrees.</returns> /// <remarks> /// AA(II), formula 12.4. /// </remarks> public static double MeanSiderealTime(double jd) { double T = (jd - 2451545.0) / 36525.0; double T2 = T * T; double T3 = T2 * T; double theta0 = 280.46061837 + 360.98564736629 * (jd - 2451545.0) + 0.000387933 * T2 - T3 / 38710000.0; theta0 = Angle.To360(theta0); return(theta0); }
/// <summary> /// Calculates longitude of Central Meridian of Jupiter in System II. /// </summary> /// <param name="jd">Julian Day</param> /// <returns>Longitude of Central Meridian of Jupiter in System II, in degrees.</returns> /// <remarks> /// This method is based on formula described here: <see href="https://www.projectpluto.com/grs_form.htm"/> /// </remarks> private static double JupiterCM2(double jd) { double jup_mean = (jd - 2455636.938) * 360.0 / 4332.89709; double eqn_center = 5.55 * Math.Sin(Angle.ToRadians(jup_mean)); double angle = (jd - 2451870.628) * 360.0 / 398.884 - eqn_center; double correction = 11 * Math.Sin(Angle.ToRadians(angle)) + 5 * Math.Cos(Angle.ToRadians(angle)) - 1.25 * Math.Cos(Angle.ToRadians(jup_mean)) - eqn_center; double cm = 181.62 + 870.1869147 * jd + correction; return(Angle.To360(cm)); }
/// <summary> /// Converts ecliptical coordinates to equatorial. /// </summary> /// <param name="ecl">Pair of ecliptical cooordinates.</param> /// <param name="epsilon">Obliquity of the ecliptic, in degrees.</param> /// <returns>Pair of equatorial coordinates.</returns> public static CrdsEquatorial ToEquatorial(this CrdsEcliptical ecl, double epsilon) { CrdsEquatorial eq = new CrdsEquatorial(); epsilon = Angle.ToRadians(epsilon); double lambda = Angle.ToRadians(ecl.Lambda); double beta = Angle.ToRadians(ecl.Beta); double Y = Math.Sin(lambda) * Math.Cos(epsilon) - Math.Tan(beta) * Math.Sin(epsilon); double X = Math.Cos(lambda); eq.Alpha = Angle.To360(Angle.ToDegrees(Math.Atan2(Y, X))); eq.Delta = Angle.ToDegrees(Math.Asin(Math.Sin(beta) * Math.Cos(epsilon) + Math.Cos(beta) * Math.Sin(epsilon) * Math.Sin(lambda))); return(eq); }
/// <summary> /// Converts equatorial coordinates (for equinox B1950.0) to galactical coordinates. /// </summary> /// <param name="eq">Equatorial coordinates for equinox B1950.0</param> /// <returns>Galactical coordinates.</returns> public static CrdsGalactical ToGalactical(this CrdsEquatorial eq) { CrdsGalactical gal = new CrdsGalactical(); double alpha0_alpha = Angle.ToRadians(192.25 - eq.Alpha); double delta = Angle.ToRadians(eq.Delta); double delta0 = Angle.ToRadians(27.4); double Y = Math.Sin(alpha0_alpha); double X = Math.Cos(alpha0_alpha) * Math.Sin(delta0) - Math.Tan(delta) * Math.Cos(delta0); double sinb = Math.Sin(delta) * Math.Sin(delta0) + Math.Cos(delta) * Math.Cos(delta0) * Math.Cos(alpha0_alpha); gal.l = Angle.To360(303 - Angle.ToDegrees(Math.Atan2(Y, X))); gal.b = Angle.ToDegrees(Math.Asin(sinb)); return(gal); }
/// <summary> /// Converts galactical coodinates to equatorial, for equinox B1950.0. /// </summary> /// <param name="gal">Galactical coodinates.</param> /// <returns>Equatorial coodinates, for equinox B1950.0.</returns> public static CrdsEquatorial ToEquatorial(this CrdsGalactical gal) { CrdsEquatorial eq = new CrdsEquatorial(); double l_l0 = Angle.ToRadians(gal.l - 123.0); double delta0 = Angle.ToRadians(27.4); double b = Angle.ToRadians(gal.b); double Y = Math.Sin(l_l0); double X = Math.Cos(l_l0) * Math.Sin(delta0) - Math.Tan(b) * Math.Cos(delta0); double sinDelta = Math.Sin(b) * Math.Sin(delta0) + Math.Cos(b) * Math.Cos(delta0) * Math.Cos(l_l0); eq.Alpha = Angle.To360(Angle.ToDegrees(Math.Atan2(Y, X)) + 12.25); eq.Delta = Angle.ToDegrees(Math.Asin(sinDelta)); return(eq); }
/// <summary> /// Converts local horizontal coordinates to equatorial coordinates. /// </summary> /// <param name="hor">Pair of local horizontal coordinates.</param> /// <param name="geo">Geographical of the observer</param> /// <param name="theta0">Local sidereal time.</param> /// <returns>Pair of equatorial coordinates</returns> public static CrdsEquatorial ToEquatorial(this CrdsHorizontal hor, CrdsGeographical geo, double theta0) { CrdsEquatorial eq = new CrdsEquatorial(); double A = Angle.ToRadians(hor.Azimuth); double h = Angle.ToRadians(hor.Altitude); double phi = Angle.ToRadians(geo.Latitude); double Y = Math.Sin(A); double X = Math.Cos(A) * Math.Sin(phi) + Math.Tan(h) * Math.Cos(phi); double H = Angle.ToDegrees(Math.Atan2(Y, X)); eq.Alpha = Angle.To360(theta0 - geo.Longitude - H); eq.Delta = Angle.ToDegrees(Math.Asin(Math.Sin(phi) * Math.Sin(h) - Math.Cos(phi) * Math.Cos(h) * Math.Cos(A))); return(eq); }
/// <summary> /// Converts equatorial coodinates to local horizontal /// </summary> /// <param name="eq">Pair of equatorial coodinates</param> /// <param name="geo">Geographical coordinates of the observer</param> /// <param name="theta0">Local sidereal time</param> /// <remarks> /// Implementation is taken from AA(I), formulae 12.5, 12.6. /// </remarks> public static CrdsHorizontal ToHorizontal(this CrdsEquatorial eq, CrdsGeographical geo, double theta0) { double H = Angle.ToRadians(HourAngle(theta0, geo.Longitude, eq.Alpha)); double phi = Angle.ToRadians(geo.Latitude); double delta = Angle.ToRadians(eq.Delta); CrdsHorizontal hor = new CrdsHorizontal(); double Y = Math.Sin(H); double X = Math.Cos(H) * Math.Sin(phi) - Math.Tan(delta) * Math.Cos(phi); hor.Altitude = Angle.ToDegrees(Math.Asin(Math.Sin(phi) * Math.Sin(delta) + Math.Cos(phi) * Math.Cos(delta) * Math.Cos(H))); hor.Azimuth = Angle.ToDegrees(Math.Atan2(Y, X)); hor.Azimuth = Angle.To360(hor.Azimuth); return(hor); }
/// <summary> /// Calculates topocentric equatorial coordinates of celestial body /// with taking into account correction for parallax. /// </summary> /// <param name="eq">Geocentric equatorial coordinates of the body</param> /// <param name="geo">Geographical coordinates of the body</param> /// <param name="theta0">Apparent sidereal time at Greenwich</param> /// <param name="pi">Parallax of a body</param> /// <returns>Topocentric equatorial coordinates of the celestial body</returns> /// <remarks> /// Method is taken from AA(II), formulae 40.6-40.7. /// </remarks> public static CrdsEquatorial ToTopocentric(this CrdsEquatorial eq, CrdsGeographical geo, double theta0, double pi) { double H = Angle.ToRadians(HourAngle(theta0, geo.Longitude, eq.Alpha)); double delta = Angle.ToRadians(eq.Delta); double sinPi = Math.Sin(Angle.ToRadians(pi)); double A = Math.Cos(delta) * Math.Sin(H); double B = Math.Cos(delta) * Math.Cos(H) - geo.RhoCosPhi * sinPi; double C = Math.Sin(delta) - geo.RhoSinPhi * sinPi; double q = Math.Sqrt(A * A + B * B + C * C); double H_ = Angle.ToDegrees(Math.Atan2(A, B)); double alpha_ = Angle.To360(theta0 - geo.Longitude - H_); double delta_ = Angle.ToDegrees(Math.Asin(C / q)); return(new CrdsEquatorial(alpha_, delta_)); }
/// <summary> /// Creates new instance of <see cref="AngleRange"/>. /// </summary> /// <param name="start">Starting position angle (start), in degrees.</param> /// <param name="range">Sector width (range), in degrees.</param> public AngleRange(double start, double range) { Start = Angle.To360(start); Range = Angle.To360(range); }
/// <summary> /// Sets horizontal coordinates values. /// </summary> /// <param name="azimuth">Azimuth, in degrees. Measured westwards from the south.</param> /// <param name="altitude">Altitude, in degrees. Positive above the horizon, negative below.</param> public void Set(double azimuth, double altitude) { Azimuth = Angle.To360(azimuth); Altitude = altitude; }
/// <summary> /// Creates a pair of equatorial coordinates with provided values of Right Ascension and Declination. /// </summary> /// <param name="alpha">Right Ascension value, in decimal degrees.</param> /// <param name="delta">Declination value, in decimal degrees.</param> public CrdsEquatorial(double alpha, double delta) { Alpha = Angle.To360(alpha); Delta = delta; }
/// <summary> /// Gets ecliptical coordinates of the Moon for given instant. /// </summary> /// <param name="jd">Julian Day.</param> /// <returns>Geocentric ecliptical coordinates of the Moon, referred to mean equinox of the date.</returns> /// <remarks> /// This method is taked from AA(II), chapter 47, /// and based on the Charpont ELP-2000/82 lunar theory. /// Accuracy of the method is 10" in longitude and 4" in latitude. /// </remarks> public static CrdsEcliptical GetCoordinates(double jd) { Initialize(); double T = (jd - 2451545.0) / 36525.0; double T2 = T * T; double T3 = T2 * T; double T4 = T3 * T; // Moon's mean longitude double L_ = 218.3164477 + 481267.88123421 * T - 0.0015786 * T2 + T3 / 538841.0 - T4 / 65194000.0; // Preserve the L_ value in degrees double Lm = L_; // Mean elongation of the Moon double D = 297.8501921 + 445267.1114034 * T - 0.0018819 * T2 + T3 / 545868.0 - T4 / 113065000.0; // Sun's mean anomaly double M = 357.5291092 + 35999.0502909 * T - 0.0001536 * T2 + T3 / 24490000.0; // Moon's mean anomaly double M_ = 134.9633964 + 477198.8675055 * T + 0.0087414 * T2 + T3 / 69699.0 - T4 / 14712000.0; // Moon's argument of latitude (mean dinstance of the Moon from its ascending node) double F = 93.2720950 + 483202.0175233 * T - 0.0036539 * T2 - T3 / 3526000.0 + T4 / 863310000.0; // Correction arguments double A1 = 119.75 + 131.849 * T; double A2 = 53.09 + 479264.290 * T; double A3 = 313.45 + 481266.484 * T; // Multiplier related to the eccentricity of the Earth orbit double E = 1 - 0.002516 * T - 0.0000074 * T2; L_ = Angle.ToRadians(L_); D = Angle.ToRadians(D); M = Angle.ToRadians(M); M_ = Angle.ToRadians(M_); F = Angle.ToRadians(F); A1 = Angle.ToRadians(A1); A2 = Angle.ToRadians(A2); A3 = Angle.ToRadians(A3); double Sum_l = 0; double Sum_b = 0; double Sum_r = 0; double[] DMMF = new double[] { D, M, M_, F }; double[] powE = new double[3] { 1, E, E *E }; double lrArg, bArg; for (int i = 0; i < 60; i++) { lrArg = 0; bArg = 0; for (int j = 0; j < 4; j++) { lrArg += DMMF[j] * ArgsLR[i, j]; bArg += DMMF[j] * ArgsB[i, j]; } Sum_l += SinCoeffLR[i] * Math.Sin(lrArg) * powE[Math.Abs(ArgsLR[i, 1])]; Sum_r += CosCoeffLR[i] * Math.Cos(lrArg) * powE[Math.Abs(ArgsLR[i, 1])]; Sum_b += CoeffB[i] * Math.Sin(bArg) * powE[Math.Abs(ArgsB[i, 1])]; } Sum_l += 3958 * Math.Sin(A1) + 1962 * Math.Sin(L_ - F) + 318 * Math.Sin(A2); Sum_b += -2235 * Math.Sin(L_) + 382 * Math.Sin(A3) + 175 * Math.Sin(A1 - F) + 175 * Math.Sin(A1 + F) + 127 * Math.Sin(L_ - M_) - 115 * Math.Sin(L_ + M_); CrdsEcliptical ecl = new CrdsEcliptical(); ecl.Lambda = Lm + Sum_l / 1e6; ecl.Lambda = Angle.To360(ecl.Lambda); ecl.Beta = Sum_b / 1e6; ecl.Distance = 385000.56 + Sum_r / 1e3; return(ecl); }
// TODO: description private static double InterpolateSiderialTime(double theta0, double n) { return(Angle.To360(theta0 + n * 360.98564736629)); }
public static double GreatRedSpotLongitude(double jd, GreatRedSpotSettings grs) { // Based on https://github.com/Stellarium/stellarium/blob/24a28f335f5277374cd387a1eda9ca7c7eaa507e/src/core/modules/Planet.cpp#L1145 return(Angle.To360(grs.Longitude + grs.MonthlyDrift * 12 * (jd - grs.Epoch) / 365.25)); }
/// <summary> /// Creates a pair of horizontal coordinates with provided values of Azimuth and Altitude. /// </summary> /// <param name="azimuth">Azimuth, in degrees. Measured westwards from the south.</param> /// <param name="altitude">Altitude, in degrees. Positive above the horizon, negative below.</param> public CrdsHorizontal(double azimuth, double altitude) { Azimuth = Angle.To360(azimuth); Altitude = altitude; }
/// <summary> /// Calculates heliocentrical coordinates of the planet using VSOP87 motion theory. /// </summary> /// <param name="planet">Planet serial number - from 1 (Mercury) to 8 (Neptune) to calculate heliocentrical coordinates.</param> /// <param name="jde">Julian Ephemeris Day</param> /// <returns>Returns heliocentric coordinates of the planet for given date.</returns> public static CrdsHeliocentrical GetPlanetCoordinates(int planet, double jde, bool highPrecision = true, bool epochOfDate = true) { Initialize(); const int L = 0; const int B = 1; const int R = 2; int p = planet - 1; int e = epochOfDate ? 1 : 0; double t = (jde - 2451545.0) / 365250.0; double t2 = t * t; double t3 = t * t2; double t4 = t * t3; double t5 = t * t4; double[] l = new double[6]; double[] b = new double[6]; double[] r = new double[6]; for (int j = 0; j < 6; j++) { l[j] = 0; for (int i = 0; i < Terms[e, p, L, j]?.Count; i++) { if (!highPrecision && i > LPTermsCount[e, p, L, j]) { break; } l[j] += Terms[e, p, L, j][i].A * Math.Cos(Terms[e, p, L, j][i].B + Terms[e, p, L, j][i].C * t); } b[j] = 0; for (int i = 0; i < Terms[e, p, B, j]?.Count; i++) { if (!highPrecision && i > LPTermsCount[e, p, B, j]) { break; } b[j] += Terms[e, p, B, j][i].A * Math.Cos(Terms[e, p, B, j][i].B + Terms[e, p, B, j][i].C * t); } r[j] = 0; for (int i = 0; i < Terms[e, p, R, j]?.Count; i++) { if (!highPrecision && i > LPTermsCount[e, p, R, j]) { break; } r[j] += Terms[e, p, R, j][i].A * Math.Cos(Terms[e, p, R, j][i].B + Terms[e, p, R, j][i].C * t); } } CrdsHeliocentrical result = new CrdsHeliocentrical(); result.L = l[0] + l[1] * t + l[2] * t2 + l[3] * t3 + l[4] * t4 + l[5] * t5; result.L = Angle.ToDegrees(result.L); result.L = Angle.To360(result.L); result.B = b[0] + b[1] * t + b[2] * t2 + b[3] * t3 + b[4] * t4 + b[5] * t5; result.B = Angle.ToDegrees(result.B); result.R = r[0] + r[1] * t + r[2] * t2 + r[3] * t3 + r[4] * t4 + r[5] * t5; return(result); }
/// <summary> /// Calculates heliocentrical coordinates of the planet using VSOP87 motion theory. /// </summary> /// <param name="planet"><see cref="Planet"/> to calculate heliocentrical coordinates.</param> /// <param name="jde">Julian Ephemeris Day</param> /// <returns>Returns heliocentric coordinates of the planet for given date.</returns> public static CrdsHeliocentrical GetPlanetCoordinates(Planet planet, double jde, bool highPrecision = true) { Initialize(highPrecision); const int L = 0; const int B = 1; const int R = 2; int p = (int)planet - 1; double t = (jde - 2451545.0) / 365250.0; double t2 = t * t; double t3 = t * t2; double t4 = t * t3; double t5 = t * t4; double[] l = new double[6]; double[] b = new double[6]; double[] r = new double[6]; List <Term>[,,] terms = highPrecision ? TermsHP : TermsLP; for (int j = 0; j < 6; j++) { l[j] = 0; for (int i = 0; i < terms[p, L, j]?.Count; i++) { l[j] += terms[p, L, j][i].A * Math.Cos(terms[p, L, j][i].B + terms[p, L, j][i].C * t); } b[j] = 0; for (int i = 0; i < terms[p, B, j]?.Count; i++) { b[j] += terms[p, B, j][i].A * Math.Cos(terms[p, B, j][i].B + terms[p, B, j][i].C * t); } r[j] = 0; for (int i = 0; i < terms[p, R, j]?.Count; i++) { r[j] += terms[p, R, j][i].A * Math.Cos(terms[p, R, j][i].B + terms[p, R, j][i].C * t); } } // Dimension coefficient. // Should be applied for the shortened VSOP87 formulae listed in AA book // because "A" coefficient expressed in 1e-8 radian for longitude and latitude and in 1e-8 AU for radius vector // Original (high-precision) version of VSOP has "A" expressed in radians and AU respectively. double d = highPrecision ? 1 : 1e-8; CrdsHeliocentrical result = new CrdsHeliocentrical(); result.L = (l[0] + l[1] * t + l[2] * t2 + l[3] * t3 + l[4] * t4 + l[5] * t5) * d; result.L = Angle.ToDegrees(result.L); result.L = Angle.To360(result.L); result.B = (b[0] + b[1] * t + b[2] * t2 + b[3] * t3 + b[4] * t4 + b[5] * t5) * d; result.B = Angle.ToDegrees(result.B); result.R = (r[0] + r[1] * t + r[2] * t2 + r[3] * t3 + r[4] * t4 + r[5] * t5) * d; return(result); }