//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); }
//Static methods /////////////////////////// Implementation //////////////////////////////////// public static CAAEclipticalElementDetails Calculate(double i0, double w0, double omega0, double JD0, double JD) { double T = (JD0 - 2451545.0) / 36525; double Tsquared = T * T; double t = (JD - JD0) / 36525; double tsquared = t * t; double tcubed = tsquared * t; //Now convert to radians double i0rad = CAACoordinateTransformation.DegreesToRadians(i0); double omega0rad = CAACoordinateTransformation.DegreesToRadians(omega0); double eta = (47.0029 - 0.06603 * T + 0.000598 * Tsquared) * t + (-0.03302 + 0.000598 * T) * tsquared + 0.00006 * tcubed; eta = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, eta)); double pi = 174.876384 * 3600 + 3289.4789 * T + 0.60622 * Tsquared - (869.8089 + 0.50491 * T) * t + 0.03536 * tsquared; pi = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, pi)); double p = (5029.0966 + 2.22226 * T - 0.000042 * Tsquared) * t + (1.11113 - 0.000042 * T) * tsquared - 0.000006 * tcubed; p = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, p)); double sini0rad = Math.Sin(i0rad); double cosi0rad = Math.Cos(i0rad); double sinomega0rad_pi = Math.Sin(omega0rad - pi); double cosomega0rad_pi = Math.Cos(omega0rad - pi); double sineta = Math.Sin(eta); double coseta = Math.Cos(eta); double A = sini0rad * sinomega0rad_pi; double B = -sineta * cosi0rad + coseta * sini0rad * cosomega0rad_pi; double irad = Math.Asin(Math.Sqrt(A * A + B * B)); CAAEclipticalElementDetails details = new CAAEclipticalElementDetails(); details.i = CAACoordinateTransformation.RadiansToDegrees(irad); double cosi = cosi0rad * coseta + sini0rad * sineta * cosomega0rad_pi; if (cosi < 0) { details.i = 180 - details.i; } double phi = pi + p; details.omega = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(A, B) + phi)); A = -sineta * sinomega0rad_pi; B = sini0rad * coseta - cosi0rad * sineta * cosomega0rad_pi; double deltaw = CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(A, B)); details.w = CAACoordinateTransformation.MapTo0To360Range(w0 + deltaw); return(details); }
public static double CorrectionInLatitude(double Longitude, double JD) { double T = (JD - 2451545) / 36525; double Ldash = Longitude - 1.397 * T - 0.00031 * T * T; //Convert to radians Ldash = CAACoordinateTransformation.DegreesToRadians(Ldash); Longitude = CAACoordinateTransformation.DegreesToRadians(Longitude); double @value = 0.03916 * (Math.Cos(Ldash) - Math.Sin(Ldash)); return(CAACoordinateTransformation.DMSToDegrees(0, 0, @value)); }
public static double ApparentEclipticLongitude(double JD) { double Longitude = GeometricFK5EclipticLongitude(JD); //Apply the correction in longitude due to nutation Longitude += CAACoordinateTransformation.DMSToDegrees(0, 0, CAANutation.NutationInLongitude(JD)); //Apply the correction in longitude due to aberration double R = CAAEarth.RadiusVector(JD); Longitude -= CAACoordinateTransformation.DMSToDegrees(0, 0, 20.4898 / R); return(Longitude); }
public static double MeanObliquityOfEcliptic(double JD) { double U = (JD - 2451545) / 3652500; double Usquared = U * U; double Ucubed = Usquared * U; double U4 = Ucubed * U; double U5 = U4 * U; double U6 = U5 * U; double U7 = U6 * U; double U8 = U7 * U; double U9 = U8 * U; double U10 = U9 * U; return(CAACoordinateTransformation.DMSToDegrees(23, 26, 21.448) - CAACoordinateTransformation.DMSToDegrees(0, 0, 4680.93) * U - CAACoordinateTransformation.DMSToDegrees(0, 0, 1.55) * Usquared + CAACoordinateTransformation.DMSToDegrees(0, 0, 1999.25) * Ucubed - CAACoordinateTransformation.DMSToDegrees(0, 0, 51.38) * U4 - CAACoordinateTransformation.DMSToDegrees(0, 0, 249.67) * U5 - CAACoordinateTransformation.DMSToDegrees(0, 0, 39.05) * U6 + CAACoordinateTransformation.DMSToDegrees(0, 0, 7.12) * U7 + CAACoordinateTransformation.DMSToDegrees(0, 0, 27.87) * U8 + CAACoordinateTransformation.DMSToDegrees(0, 0, 5.79) * U9 + CAACoordinateTransformation.DMSToDegrees(0, 0, 2.45) * U10); }
public static CAA3DCoordinate ConvertVSOPToFK5AnyEquinox(CAA3DCoordinate @value, double JDEquinox) { double t = (JDEquinox - 2451545.0) / 36525; double tsquared = t * t; double tcubed = tsquared * t; double sigma = 2306.2181 * t + 0.30188 * tsquared + 0.017988 * tcubed; sigma = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, sigma)); double zeta = 2306.2181 * t + 1.09468 * tsquared + 0.018203 * tcubed; zeta = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, zeta)); double phi = 2004.3109 * t - 0.42665 * tsquared - 0.041833 * tcubed; phi = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, phi)); double cossigma = Math.Cos(sigma); double coszeta = Math.Cos(zeta); double cosphi = Math.Cos(phi); double sinsigma = Math.Sin(sigma); double sinzeta = Math.Sin(zeta); double sinphi = Math.Sin(phi); double xx = cossigma * coszeta * cosphi - sinsigma * sinzeta; double xy = sinsigma * coszeta + cossigma * sinzeta * cosphi; double xz = cossigma * sinphi; double yx = -cossigma * sinzeta - sinsigma * coszeta * cosphi; double yy = cossigma * coszeta - sinsigma * sinzeta * cosphi; double yz = -sinsigma * sinphi; double zx = -coszeta * sinphi; double zy = -sinzeta * sinphi; double zz = cosphi; CAA3DCoordinate result = new CAA3DCoordinate(); result.X = xx * @value.X + yx * @value.Y + zx * @value.Z; result.Y = xy * @value.X + yy * @value.Y + zy * @value.Z; result.Z = xz * @value.X + yz * @value.Y + zz * @value.Z; return(result); }
public static CAA2DCoordinate PrecessEquatorialFK4(double Alpha, double Delta, double JD0, double JD) { double T = (JD0 - 2415020.3135) / 36524.2199; double t = (JD - JD0) / 36524.2199; double tsquared = t * t; double tcubed = tsquared * t; //Now convert to radians Alpha = CAACoordinateTransformation.HoursToRadians(Alpha); Delta = CAACoordinateTransformation.DegreesToRadians(Delta); double sigma = (2304.250 + 1.396 * T) * t + 0.302 * tsquared + 0.018 * tcubed; sigma = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, sigma)); double zeta = 0.791 * tsquared + 0.001 * tcubed; zeta = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, zeta)); zeta += sigma; double phi = (2004.682 - 0.853 * T) * t - 0.426 * tsquared - 0.042 * tcubed; phi = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, phi)); double A = Math.Cos(Delta) * Math.Sin(Alpha + sigma); double B = Math.Cos(phi) * Math.Cos(Delta) * Math.Cos(Alpha + sigma) - Math.Sin(phi) * Math.Sin(Delta); double C = Math.Sin(phi) * Math.Cos(Delta) * Math.Cos(Alpha + sigma) + Math.Cos(phi) * Math.Sin(Delta); CAA2DCoordinate @value = new CAA2DCoordinate(); @value.X = CAACoordinateTransformation.RadiansToHours(Math.Atan2(A, B) + zeta); if (@value.X < 0) { @value.X += 24; } @value.Y = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(C)); return(@value); }
//Static methods public static CAA2DCoordinate PrecessEquatorial(double Alpha, double Delta, double JD0, double JD) { double T = (JD0 - 2451545.0) / 36525; double Tsquared = T * T; double t = (JD - JD0) / 36525; double tsquared = t * t; double tcubed = tsquared * t; //Now convert to radians Alpha = CAACoordinateTransformation.HoursToRadians(Alpha); Delta = CAACoordinateTransformation.DegreesToRadians(Delta); double sigma = (2306.2181 + 1.39656 * T - 0.000139 * Tsquared) * t + (0.30188 - 0.0000344 * T) * tsquared + 0.017988 * tcubed; sigma = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, sigma)); double zeta = (2306.2181 + 1.39656 * T - 0.000138 * Tsquared) * t + (1.09468 + 0.000066 * T) * tsquared + 0.018203 * tcubed; zeta = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, zeta)); double phi = (2004.3109 - 0.8533 * T - 0.000217 * Tsquared) * t - (0.42665 + 0.000217 * T) * tsquared - 0.041833 * tcubed; phi = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, phi)); double A = Math.Cos(Delta) * Math.Sin(Alpha + sigma); double B = Math.Cos(phi) * Math.Cos(Delta) * Math.Cos(Alpha + sigma) - Math.Sin(phi) * Math.Sin(Delta); double C = Math.Sin(phi) * Math.Cos(Delta) * Math.Cos(Alpha + sigma) + Math.Cos(phi) * Math.Sin(Delta); CAA2DCoordinate @value = new CAA2DCoordinate(); @value.X = CAACoordinateTransformation.RadiansToHours(Math.Atan2(A, B) + zeta); if (@value.X < 0) { @value.X += 24; } @value.Y = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(C)); return(@value); }
public static CAA2DCoordinate PrecessEcliptic(double Lambda, double Beta, double JD0, double JD) { double T = (JD0 - 2451545.0) / 36525; double Tsquared = T * T; double t = (JD - JD0) / 36525; double tsquared = t * t; double tcubed = tsquared * t; //Now convert to radians Lambda = CAACoordinateTransformation.DegreesToRadians(Lambda); Beta = CAACoordinateTransformation.DegreesToRadians(Beta); double eta = (47.0029 - 0.06603 * T + 0.000598 * Tsquared) * t + (-0.03302 + 0.000598 * T) * tsquared + 0.00006 * tcubed; eta = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, eta)); double pi = 174.876384 * 3600 + 3289.4789 * T + 0.60622 * Tsquared - (869.8089 + 0.50491 * T) * t + 0.03536 * tsquared; pi = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, pi)); double p = (5029.0966 + 2.22226 * T - 0.000042 * Tsquared) * t + (1.11113 - 0.000042 * T) * tsquared - 0.000006 * tcubed; p = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, p)); double A = Math.Cos(eta) * Math.Cos(Beta) * Math.Sin(pi - Lambda) - Math.Sin(eta) * Math.Sin(Beta); double B = Math.Cos(Beta) * Math.Cos(pi - Lambda); double C = Math.Cos(eta) * Math.Sin(Beta) + Math.Sin(eta) * Math.Cos(Beta) * Math.Sin(pi - Lambda); CAA2DCoordinate @value = new CAA2DCoordinate(); @value.X = CAACoordinateTransformation.RadiansToDegrees(p + pi - Math.Atan2(A, B)); if (@value.X < 0) { @value.X += 360; } @value.Y = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(C)); return(@value); }
//Static methods //////////////////////////////// Implementation /////////////////////////////// public static CAAPhysicalSunDetails Calculate(double JD) { double theta = CAACoordinateTransformation.MapTo0To360Range((JD - 2398220) * 360 / 25.38); double I = 7.25; double K = 73.6667 + 1.3958333 * (JD - 2396758) / 36525; //Calculate the apparent longitude of the sun (excluding the effect of nutation) double L = CAAEarth.EclipticLongitude(JD); double R = CAAEarth.RadiusVector(JD); double SunLong = L + 180 - CAACoordinateTransformation.DMSToDegrees(0, 0, 20.4898 / R); double SunLongDash = SunLong + CAACoordinateTransformation.DMSToDegrees(0, 0, CAANutation.NutationInLongitude(JD)); double epsilon = CAANutation.TrueObliquityOfEcliptic(JD); //Convert to radians epsilon = CAACoordinateTransformation.DegreesToRadians(epsilon); SunLong = CAACoordinateTransformation.DegreesToRadians(SunLong); SunLongDash = CAACoordinateTransformation.DegreesToRadians(SunLongDash); K = CAACoordinateTransformation.DegreesToRadians(K); I = CAACoordinateTransformation.DegreesToRadians(I); theta = CAACoordinateTransformation.DegreesToRadians(theta); double x = Math.Atan(-Math.Cos(SunLong) * Math.Tan(epsilon)); double y = Math.Atan(-Math.Cos(SunLong - K) * Math.Tan(I)); CAAPhysicalSunDetails details = new CAAPhysicalSunDetails(); details.P = CAACoordinateTransformation.RadiansToDegrees(x + y); details.B0 = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sin(SunLong - K) * Math.Sin(I))); double eta = Math.Atan(Math.Tan(SunLong - K) * Math.Cos(I)); details.L0 = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(eta - theta)); return(details); }
public static double TrueObliquityOfEcliptic(double JD) { return(MeanObliquityOfEcliptic(JD) + CAACoordinateTransformation.DMSToDegrees(0, 0, NutationInObliquity(JD))); }
public static CAAEllipticalPlanetaryDetails Calculate(double JD, EllipticalObject @object) { //What will the the return value CAAEllipticalPlanetaryDetails details = new CAAEllipticalPlanetaryDetails(); double JD0 = JD; double L0 = 0; double B0 = 0; double R0 = 0; double cosB0 = 0; if (@object != EllipticalObject.SUN) { L0 = CAAEarth.EclipticLongitude(JD0); B0 = CAAEarth.EclipticLatitude(JD0); R0 = CAAEarth.RadiusVector(JD0); L0 = CAACoordinateTransformation.DegreesToRadians(L0); B0 = CAACoordinateTransformation.DegreesToRadians(B0); cosB0 = Math.Cos(B0); } //Calculate the initial values double L = 0; double B = 0; double R = 0; double Lrad; double Brad; double cosB; double cosL; double x; double y; double z; bool bRecalc = true; bool bFirstRecalc = true; double LPrevious = 0; double BPrevious = 0; double RPrevious = 0; while (bRecalc) { switch (@object) { case EllipticalObject.SUN: { L = CAASun.GeometricEclipticLongitude(JD0); B = CAASun.GeometricEclipticLatitude(JD0); R = CAAEarth.RadiusVector(JD0); break; } case EllipticalObject.MERCURY: { L = CAAMercury.EclipticLongitude(JD0); B = CAAMercury.EclipticLatitude(JD0); R = CAAMercury.RadiusVector(JD0); break; } case EllipticalObject.VENUS: { L = CAAVenus.EclipticLongitude(JD0); B = CAAVenus.EclipticLatitude(JD0); R = CAAVenus.RadiusVector(JD0); break; } case EllipticalObject.MARS: { L = CAAMars.EclipticLongitude(JD0); B = CAAMars.EclipticLatitude(JD0); R = CAAMars.RadiusVector(JD0); break; } case EllipticalObject.JUPITER: { L = CAAJupiter.EclipticLongitude(JD0); B = CAAJupiter.EclipticLatitude(JD0); R = CAAJupiter.RadiusVector(JD0); break; } case EllipticalObject.SATURN: { L = CAASaturn.EclipticLongitude(JD0); B = CAASaturn.EclipticLatitude(JD0); R = CAASaturn.RadiusVector(JD0); break; } case EllipticalObject.URANUS: { L = CAAUranus.EclipticLongitude(JD0); B = CAAUranus.EclipticLatitude(JD0); R = CAAUranus.RadiusVector(JD0); break; } case EllipticalObject.NEPTUNE: { L = CAANeptune.EclipticLongitude(JD0); B = CAANeptune.EclipticLatitude(JD0); R = CAANeptune.RadiusVector(JD0); break; } case EllipticalObject.PLUTO: { L = CAAPluto.EclipticLongitude(JD0); B = CAAPluto.EclipticLatitude(JD0); R = CAAPluto.RadiusVector(JD0); break; } default: { Debug.Assert(false); break; } } if (!bFirstRecalc) { bRecalc = ((Math.Abs(L - LPrevious) > 0.00001) || (Math.Abs(B - BPrevious) > 0.00001) || (Math.Abs(R - RPrevious) > 0.000001)); LPrevious = L; BPrevious = B; RPrevious = R; } else { bFirstRecalc = false; } //Calculate the new value if (bRecalc) { double distance = 0; if (@object != EllipticalObject.SUN) { Lrad = CAACoordinateTransformation.DegreesToRadians(L); Brad = CAACoordinateTransformation.DegreesToRadians(B); cosB = Math.Cos(Brad); cosL = Math.Cos(Lrad); x = R * cosB * cosL - R0 * cosB0 * Math.Cos(L0); y = R * cosB * Math.Sin(Lrad) - R0 * cosB0 * Math.Sin(L0); z = R * Math.Sin(Brad) - R0 * Math.Sin(B0); distance = Math.Sqrt(x * x + y * y + z * z); } else { distance = R; //Distance to the sun from the earth is in fact the radius vector } //Prepare for the next loop around JD0 = JD - CAAElliptical.DistanceToLightTime(distance); } } Lrad = CAACoordinateTransformation.DegreesToRadians(L); Brad = CAACoordinateTransformation.DegreesToRadians(B); cosB = Math.Cos(Brad); cosL = Math.Cos(Lrad); x = R * cosB * cosL - R0 * cosB0 * Math.Cos(L0); y = R * cosB * Math.Sin(Lrad) - R0 * cosB0 * Math.Sin(L0); z = R * Math.Sin(Brad) - R0 * Math.Sin(B0); double x2 = x * x; double y2 = y * y; details.ApparentGeocentricLatitude = CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(z, Math.Sqrt(x2 + y2))); details.ApparentGeocentricDistance = Math.Sqrt(x2 + y2 + z * z); details.ApparentGeocentricLongitude = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(y, x))); details.ApparentLightTime = CAAElliptical.DistanceToLightTime(details.ApparentGeocentricDistance); //Adjust for Aberration CAA2DCoordinate Aberration = CAAAberration.EclipticAberration(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, JD); details.ApparentGeocentricLongitude += Aberration.X; details.ApparentGeocentricLatitude += Aberration.Y; //convert to the FK5 system double DeltaLong = CAAFK5.CorrectionInLongitude(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, JD); details.ApparentGeocentricLatitude += CAAFK5.CorrectionInLatitude(details.ApparentGeocentricLongitude, JD); details.ApparentGeocentricLongitude += DeltaLong; //Correct for nutation double NutationInLongitude = CAANutation.NutationInLongitude(JD); double Epsilon = CAANutation.TrueObliquityOfEcliptic(JD); details.ApparentGeocentricLongitude += CAACoordinateTransformation.DMSToDegrees(0, 0, NutationInLongitude); //Convert to RA and Dec CAA2DCoordinate ApparentEqu = CAACoordinateTransformation.Ecliptic2Equatorial(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, Epsilon); details.ApparentGeocentricRA = ApparentEqu.X; details.ApparentGeocentricDeclination = ApparentEqu.Y; return(details); }