/// <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; }
// TODO: docs, tests public static double LongitudeDifference(double eclipticalLongitudeSun, double eclipticalLongitudeBody) { double[] longitudes = new[] { eclipticalLongitudeBody, eclipticalLongitudeSun }; Angle.Align(longitudes); return(longitudes[0] - longitudes[1]); }
/// <summary> /// Gets phase value (illuminated fraction of the disk). /// </summary> /// <param name="phaseAngle">Phase angle of celestial body, in degrees.</param> /// <returns>Illuminated fraction of the disk, from 0 to 1.</returns> /// <remarks> /// AA(II), formula 48.1 /// </remarks> // TODO: tests public static double Phase(double phaseAngle) { return((1 + Math.Cos(Angle.ToRadians(phaseAngle))) / 2); }
/// <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); }