public static AAS2DCoordinate Equatorial2Topocentric(double Alpha, double Delta, double Distance, double Longitude, double Latitude, double Height, double JD) { double RhoSinThetaPrime = AASGlobe.RhoSinThetaPrime(Latitude, Height); double RhoCosThetaPrime = AASGlobe.RhoCosThetaPrime(Latitude, Height); //Calculate the Sidereal time double theta = AASSidereal.ApparentGreenwichSiderealTime(JD); //Convert to radians Delta = AASCoordinateTransformation.DegreesToRadians(Delta); double cosDelta = Math.Cos(Delta); //Calculate the Parallax double pi = Math.Asin(g_AAParallax_C1 / Distance); double sinpi = Math.Sin(pi); //Calculate the hour angle double H = AASCoordinateTransformation.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); AAS2DCoordinate Topocentric = new AAS2DCoordinate { X = AASCoordinateTransformation.MapTo0To24Range(Alpha + AASCoordinateTransformation.RadiansToHours(DeltaAlpha)), Y = AASCoordinateTransformation.RadiansToDegrees(Math.Atan2((Math.Sin(Delta) - RhoSinThetaPrime * sinpi) * Math.Cos(DeltaAlpha), cosDelta - RhoCosThetaPrime * sinpi * cosH)) }; return(Topocentric); }
public static AAS2DCoordinate 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 = AASCoordinateTransformation.HoursToRadians(Alpha); Delta = AASCoordinateTransformation.DegreesToRadians(Delta); double sigma = AASCoordinateTransformation.DegreesToRadians(AASCoordinateTransformation.DMSToDegrees(0, 0, (2304.250 + 1.396 * T) * t + 0.302 * tsquared + 0.018 * tcubed)); double zeta = AASCoordinateTransformation.DegreesToRadians(AASCoordinateTransformation.DMSToDegrees(0, 0, 0.791 * tsquared + 0.001 * tcubed)) + sigma; double phi = AASCoordinateTransformation.DegreesToRadians(AASCoordinateTransformation.DMSToDegrees(0, 0, (2004.682 - 0.853 * T) * t - 0.426 * tsquared - 0.042 * tcubed)); 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); double DeltaAlpha = AASCoordinateTransformation.DMSToDegrees(0, 0, 0.0775 + 0.0850 * T); AAS2DCoordinate value = new AAS2DCoordinate(); value.X = AASCoordinateTransformation.MapTo0To24Range(AASCoordinateTransformation.RadiansToHours(Math.Atan2(A, B) + zeta) + DeltaAlpha); value.Y = AASCoordinateTransformation.RadiansToDegrees(Math.Asin(C)); return(value); }
public static AAS2DCoordinate 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 = AASCoordinateTransformation.HoursToRadians(Alpha); Delta = AASCoordinateTransformation.DegreesToRadians(Delta); double sigma = AASCoordinateTransformation.DegreesToRadians(AASCoordinateTransformation.DMSToDegrees(0, 0, (2306.2181 + 1.39656 * T - 0.000139 * Tsquared) * t + (0.30188 - 0.000344 * T) * tsquared + 0.017998 * tcubed)); double zeta = AASCoordinateTransformation.DegreesToRadians(AASCoordinateTransformation.DMSToDegrees(0, 0, (2306.2181 + 1.39656 * T - 0.000139 * Tsquared) * t + (1.09468 + 0.000066 * T) * tsquared + 0.018203 * tcubed)); double phi = AASCoordinateTransformation.DegreesToRadians(AASCoordinateTransformation.DMSToDegrees(0, 0, (2004.3109 - 0.8533 * T - 0.000217 * Tsquared) * t - (0.42665 + 0.000217 * T) * tsquared - 0.041833 * tcubed)); 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); AAS2DCoordinate value = new AAS2DCoordinate(); value.X = AASCoordinateTransformation.MapTo0To24Range(AASCoordinateTransformation.RadiansToHours(Math.Atan2(A, B) + zeta)); value.Y = AASCoordinateTransformation.RadiansToDegrees(Math.Asin(C)); return(value); }
public static AAS2DCoordinate AdjustPositionUsingMotionInSpace(double r, double DeltaR, double t, double Alpha, double Delta, double PMAlpha, double PMDelta) { //Convert DeltaR from km/s to Parsecs / Year DeltaR /= 977792; //Convert from seconds of time to Radians / Year PMAlpha /= 13751; //Convert from seconds of arc to Radians / Year PMDelta /= 206265; //Now convert to radians Alpha = AASCoordinateTransformation.HoursToRadians(Alpha); Delta = AASCoordinateTransformation.DegreesToRadians(Delta); double x = r * Math.Cos(Delta) * Math.Cos(Alpha); double y = r * Math.Cos(Delta) * Math.Sin(Alpha); double z = r * Math.Sin(Delta); double DeltaX = x / r * DeltaR - z * PMDelta * Math.Cos(Alpha) - y * PMAlpha; double DeltaY = y / r * DeltaR - z * PMDelta * Math.Sin(Alpha) + x * PMAlpha; double DeltaZ = z / r * DeltaR + r * PMDelta * Math.Cos(Delta); x += t * DeltaX; y += t * DeltaY; z += t * DeltaZ; AAS2DCoordinate value = new AAS2DCoordinate(); value.X = AASCoordinateTransformation.MapTo0To24Range(AASCoordinateTransformation.RadiansToHours(Math.Atan2(y, x))); value.Y = AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(z, Math.Sqrt(x * x + y * y))); return(value); }
public static double MeanGreenwichSiderealTime(double JD) { //Get the Julian day for the same day at midnight long Year = 0; long Month = 0; long Day = 0; long Hour = 0; long Minute = 0; double Second = 0; AASDate date = new AASDate(); date.Set(JD, AASDate.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 = AASCoordinateTransformation.DegreesToHours(Value); return(AASCoordinateTransformation.MapTo0To24Range(Value)); }
public static double ApparentGreenwichSiderealTime(double JD) { double MeanObliquity = AASNutation.MeanObliquityOfEcliptic(JD); double TrueObliquity = MeanObliquity + AASNutation.NutationInObliquity(JD) / 3600; double NutationInLongitude = AASNutation.NutationInLongitude(JD); double Value = MeanGreenwichSiderealTime(JD) + (NutationInLongitude * Math.Cos(AASCoordinateTransformation.DegreesToRadians(TrueObliquity)) / 54000); return(AASCoordinateTransformation.MapTo0To24Range(Value)); }
private static void CorrectRAValuesForInterpolation(ref double Alpha1, ref double Alpha2, ref double Alpha3) { //Ensure the RA values are corrected for interpolation. Due to important Remark 2 by Meeus on Interopolation of RA values Alpha1 = AASCoordinateTransformation.MapTo0To24Range(Alpha1); Alpha2 = AASCoordinateTransformation.MapTo0To24Range(Alpha2); Alpha3 = AASCoordinateTransformation.MapTo0To24Range(Alpha3); if (Math.Abs(Alpha2 - Alpha1) > 12.0) { if (Alpha2 > Alpha1) { Alpha1 += 24; } else { Alpha2 += 24; } } if (Math.Abs(Alpha3 - Alpha2) > 12.0) { if (Alpha3 > Alpha2) { Alpha2 += 24; } else { Alpha3 += 24; } } if (Math.Abs(Alpha2 - Alpha1) > 12.0) { if (Alpha2 > Alpha1) { Alpha1 += 24; } else { Alpha2 += 24; } } if (Math.Abs(Alpha3 - Alpha2) > 12.0) { if (Alpha3 > Alpha2) { Alpha2 += 24; } else { Alpha3 += 24; } } }
public static AASNearParabolicObjectDetails Calculate(double JD, ref AASNearParabolicObjectElements elements, bool bHighPrecision) { double Epsilon = AASNutation.MeanObliquityOfEcliptic(elements.JDEquinox); double JD0 = JD; //What will be the return value AASNearParabolicObjectDetails details = new AASNearParabolicObjectDetails(); Epsilon = AASCoordinateTransformation.DegreesToRadians(Epsilon); double omega = AASCoordinateTransformation.DegreesToRadians(elements.omega); double w = AASCoordinateTransformation.DegreesToRadians(elements.w); double i = AASCoordinateTransformation.DegreesToRadians(elements.i); double sinEpsilon = Math.Sin(Epsilon); double cosEpsilon = Math.Cos(Epsilon); double sinOmega = Math.Sin(omega); double cosOmega = Math.Cos(omega); double cosi = Math.Cos(i); double sini = Math.Sin(i); double F = cosOmega; double G = sinOmega * cosEpsilon; double H = sinOmega * sinEpsilon; double P = -sinOmega * cosi; double Q = cosOmega * cosi * cosEpsilon - sini * sinEpsilon; double R = cosOmega * cosi * sinEpsilon + sini * cosEpsilon; double a = Math.Sqrt(F * F + P * P); double b = Math.Sqrt(G * G + Q * Q); double c = Math.Sqrt(H * H + R * R); double A = Math.Atan2(F, P); double B = Math.Atan2(G, Q); double C = Math.Atan2(H, R); AAS3DCoordinate SunCoord = AASSun.EquatorialRectangularCoordinatesAnyEquinox(JD, elements.JDEquinox, bHighPrecision); for (int j = 0; j < 2; j++) { double v = 0; double r = 0; CalulateTrueAnnomalyAndRadius(JD0, ref elements, ref v, ref r); double x = r * a * Math.Sin(A + w + v); double y = r * b * Math.Sin(B + w + v); double z = r * c * Math.Sin(C + w + v); if (j == 0) { details.HeliocentricRectangularEquatorial.X = x; details.HeliocentricRectangularEquatorial.Y = y; details.HeliocentricRectangularEquatorial.Z = z; //Calculate the heliocentric ecliptic coordinates also double u = w + v; double cosu = Math.Cos(u); double sinu = Math.Sin(u); details.HeliocentricRectangularEcliptical.X = r * (cosOmega * cosu - sinOmega * sinu * cosi); details.HeliocentricRectangularEcliptical.Y = r * (sinOmega * cosu + cosOmega * sinu * cosi); details.HeliocentricRectangularEcliptical.Z = r * sini * sinu; details.HeliocentricEclipticLongitude = AASCoordinateTransformation.MapTo0To360Range(AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(details.HeliocentricRectangularEcliptical.Y, details.HeliocentricRectangularEcliptical.X))); details.HeliocentricEclipticLatitude = AASCoordinateTransformation.RadiansToDegrees(Math.Asin(details.HeliocentricRectangularEcliptical.Z / r)); } double psi = SunCoord.X + x; double nu = SunCoord.Y + y; double sigma = SunCoord.Z + z; double Alpha = Math.Atan2(nu, psi); Alpha = AASCoordinateTransformation.RadiansToDegrees(Alpha); double Delta = Math.Atan2(sigma, Math.Sqrt(psi * psi + nu * nu)); Delta = AASCoordinateTransformation.RadiansToDegrees(Delta); double Distance = Math.Sqrt(psi * psi + nu * nu + sigma * sigma); if (j == 0) { details.TrueGeocentricRA = AASCoordinateTransformation.MapTo0To24Range(Alpha / 15); details.TrueGeocentricDeclination = Delta; details.TrueGeocentricDistance = Distance; details.TrueGeocentricLightTime = AASElliptical.DistanceToLightTime(Distance); } else { details.AstrometricGeocentricRA = AASCoordinateTransformation.MapTo0To24Range(Alpha / 15); details.AstrometricGeocentricDeclination = Delta; details.AstrometricGeocentricDistance = Distance; details.AstrometricGeocentricLightTime = AASElliptical.DistanceToLightTime(Distance); double RES = Math.Sqrt(SunCoord.X * SunCoord.X + SunCoord.Y * SunCoord.Y + SunCoord.Z * SunCoord.Z); details.Elongation = AASCoordinateTransformation.RadiansToDegrees(Math.Acos((RES * RES + Distance * Distance - r * r) / (2 * RES * Distance))); details.PhaseAngle = AASCoordinateTransformation.RadiansToDegrees(Math.Acos((r * r + Distance * Distance - RES * RES) / (2 * r * Distance))); } if (j == 0) //Prepare for the next loop around { JD0 = JD - details.TrueGeocentricLightTime; } } return(details); }