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 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 = AASCoordinateTransformation.DegreesToRadians(Lambda); Beta = AASCoordinateTransformation.DegreesToRadians(Beta); double eta = AASCoordinateTransformation.DegreesToRadians(AASCoordinateTransformation.DMSToDegrees(0, 0, (47.0029 - 0.06603 * T + 0.000598 * Tsquared) * t + (-0.03302 + 0.000598 * T) * tsquared + 0.00006 * tcubed)); double pi = AASCoordinateTransformation.DegreesToRadians(AASCoordinateTransformation.DMSToDegrees(0, 0, 174.876384 * 3600 + 3289.4789 * T + 0.60622 * Tsquared - (869.8089 + 0.50491 * T) * t + 0.03536 * tsquared)); double p = AASCoordinateTransformation.DegreesToRadians(AASCoordinateTransformation.DMSToDegrees(0, 0, (5029.0966 + 2.22226 * T - 0.000042 * Tsquared) * t + (1.11113 - 0.000042 * T) * tsquared - 0.000006 * tcubed)); 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); AAS2DCoordinate value = new AAS2DCoordinate(); value.X = AASCoordinateTransformation.MapTo0To360Range(AASCoordinateTransformation.RadiansToDegrees(p + pi - Math.Atan2(A, B))); 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 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 = AASCoordinateTransformation.MapTo0To360Range(280.4664567 + 360007.6982779 * rho + 0.03032028 * rhosquared + rhocubed / 49931 - rho4 / 15300 - rho5 / 2000000); //Calculate the Suns apparent right ascension double SunLong = AASSun.ApparentEclipticLongitude(JD); double SunLat = AASSun.ApparentEclipticLatitude(JD); double epsilon = AASNutation.TrueObliquityOfEcliptic(JD); AAS2DCoordinate Equatorial = AASCoordinateTransformation.Ecliptic2Equatorial(SunLong, SunLat, epsilon); epsilon = AASCoordinateTransformation.DegreesToRadians(epsilon); double E = L0 - 0.0057183 - Equatorial.X * 15 + AASCoordinateTransformation.DMSToDegrees(0, 0, AASNutation.NutationInLongitude(JD)) * Math.Cos(epsilon); if (E > 180) { E = -(360 - E); } E *= 4; //Convert to minutes of time return(E); }
public static AAS2DCoordinate Equatorial2TopocentricDelta(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); //Calculate the hour angle double H = AASCoordinateTransformation.HoursToRadians(theta - Longitude / 15 - Alpha); double cosH = Math.Cos(H); double sinH = Math.Sin(H); AAS2DCoordinate DeltaTopocentric = new AAS2DCoordinate { X = AASCoordinateTransformation.RadiansToHours(-pi * RhoCosThetaPrime * sinH / cosDelta), Y = AASCoordinateTransformation.RadiansToDegrees(-pi * (RhoSinThetaPrime * cosDelta - RhoCosThetaPrime * cosH * Math.Sin(Delta))) }; return(DeltaTopocentric); }
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); }
private static void CalculateSetHelper(ref AASRiseTransitSetDetails details, double theta0, double deltaT, double Alpha1, double Delta1, double Alpha2, double Delta2, double Alpha3, double Delta3, double Longitude, double Latitude, double LatitudeRad, double h0, ref double M2) { for (int i = 0; i < 2; i++) { //Calculate the details of setting if (details.bSetValid) { double theta1 = theta0 + 360.985647 * M2; theta1 = AASCoordinateTransformation.MapTo0To360Range(theta1); double n = M2 + deltaT / 86400; double Alpha = AASInterpolate.Interpolate(n, Alpha1, Alpha2, Alpha3); double Delta = AASInterpolate.Interpolate(n, Delta1, Delta2, Delta3); double H = theta1 - Longitude - Alpha * 15; AAS2DCoordinate Horizontal = AASCoordinateTransformation.Equatorial2Horizontal(H / 15, Delta, Latitude); double DeltaM = (Horizontal.Y - h0) / (360 * Math.Cos(AASCoordinateTransformation.DegreesToRadians(Delta)) * Math.Cos(LatitudeRad) * Math.Sin(AASCoordinateTransformation.DegreesToRadians(H))); M2 += DeltaM; if ((M2 < 0) || (M2 >= 1)) { details.bSetValid = false; } } } }
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 AdjustPositionUsingUniformProperMotion(double t, double Alpha, double Delta, double PMAlpha, double PMDelta) { AAS2DCoordinate value = new AAS2DCoordinate { X = Alpha + (PMAlpha * t / 3600), Y = Delta + (PMDelta * t / 3600) }; return(value); }
public static AASPhysicalMoonDetails CalculateGeocentric(double JD) { double Lambda = 0; double Beta = 0; double epsilon = 0; AAS2DCoordinate Equatorial = new AAS2DCoordinate(); return(CalculateHelper(JD, ref Lambda, ref Beta, ref epsilon, ref Equatorial)); }
public static AAS2DCoordinate EquatorialPMToEcliptic(double Alpha, double Delta, double Beta, double PMAlpha, double PMDelta, double Epsilon) { //Convert to radians Epsilon = AASCoordinateTransformation.DegreesToRadians(Epsilon); Alpha = AASCoordinateTransformation.HoursToRadians(Alpha); Delta = AASCoordinateTransformation.DegreesToRadians(Delta); Beta = AASCoordinateTransformation.DegreesToRadians(Beta); double cosb = Math.Cos(Beta); double sinEpsilon = Math.Sin(Epsilon); AAS2DCoordinate value = new AAS2DCoordinate { X = (PMDelta * sinEpsilon * Math.Cos(Alpha) + PMAlpha * Math.Cos(Delta) * (Math.Cos(Epsilon) * Math.Cos(Delta) + sinEpsilon * Math.Sin(Delta) * Math.Sin(Alpha))) / (cosb * cosb), Y = (PMDelta * (Math.Cos(Epsilon) * Math.Cos(Delta) + sinEpsilon * Math.Sin(Delta) * Math.Sin(Alpha)) - PMAlpha * sinEpsilon * Math.Cos(Alpha) * Math.Cos(Delta)) / cosb }; return(value); }
public static AAS2DCoordinate Equatorial2Horizontal(double LocalHourAngle, double Delta, double Latitude) { LocalHourAngle = HoursToRadians(LocalHourAngle); Delta = DegreesToRadians(Delta); Latitude = DegreesToRadians(Latitude); AAS2DCoordinate Horizontal = new AAS2DCoordinate { X = RadiansToDegrees(Math.Atan2(Math.Sin(LocalHourAngle), Math.Cos(LocalHourAngle) * Math.Sin(Latitude) - Math.Tan(Delta) * Math.Cos(Latitude))) }; if (Horizontal.X < 0) { Horizontal.X += 360; } Horizontal.Y = RadiansToDegrees(Math.Asin(Math.Sin(Latitude) * Math.Sin(Delta) + Math.Cos(Latitude) * Math.Cos(Delta) * Math.Cos(LocalHourAngle))); return(Horizontal); }
public static AAS2DCoordinate Equatorial2Ecliptic(double Alpha, double Delta, double Epsilon) { Alpha = HoursToRadians(Alpha); Delta = DegreesToRadians(Delta); Epsilon = DegreesToRadians(Epsilon); AAS2DCoordinate Ecliptic = new AAS2DCoordinate { X = RadiansToDegrees(Math.Atan2(Math.Sin(Alpha) * Math.Cos(Epsilon) + Math.Tan(Delta) * Math.Sin(Epsilon), Math.Cos(Alpha))) }; if (Ecliptic.X < 0) { Ecliptic.X += 360; } Ecliptic.Y = RadiansToDegrees(Math.Asin(Math.Sin(Delta) * Math.Cos(Epsilon) - Math.Cos(Delta) * Math.Sin(Epsilon) * Math.Sin(Alpha))); return(Ecliptic); }
public static AAS2DCoordinate Ecliptic2Equatorial(double Lambda, double Beta, double Epsilon) { Lambda = DegreesToRadians(Lambda); Beta = DegreesToRadians(Beta); Epsilon = DegreesToRadians(Epsilon); AAS2DCoordinate Equatorial = new AAS2DCoordinate { X = RadiansToHours(Math.Atan2(Math.Sin(Lambda) * Math.Cos(Epsilon) - Math.Tan(Beta) * Math.Sin(Epsilon), Math.Cos(Lambda))) }; if (Equatorial.X < 0) { Equatorial.X += 24; } Equatorial.Y = RadiansToDegrees(Math.Asin(Math.Sin(Beta) * Math.Cos(Epsilon) + Math.Cos(Beta) * Math.Sin(Epsilon) * Math.Sin(Lambda))); return(Equatorial); }
public static AAS2DCoordinate Equatorial2Galactic(double Alpha, double Delta) { Alpha = 192.25 - HoursToDegrees(Alpha); Alpha = DegreesToRadians(Alpha); Delta = DegreesToRadians(Delta); AAS2DCoordinate Galactic = new AAS2DCoordinate { X = RadiansToDegrees(Math.Atan2(Math.Sin(Alpha), Math.Cos(Alpha) * Math.Sin(DegreesToRadians(27.4)) - Math.Tan(Delta) * Math.Cos(DegreesToRadians(27.4)))) }; Galactic.X = 303 - Galactic.X; if (Galactic.X >= 360) { Galactic.X -= 360; } Galactic.Y = RadiansToDegrees(Math.Asin(Math.Sin(Delta) * Math.Sin(DegreesToRadians(27.4)) + Math.Cos(Delta) * Math.Cos(DegreesToRadians(27.4)) * Math.Cos(Alpha))); return(Galactic); }
public static AAS2DCoordinate Horizontal2Equatorial(double Azimuth, double Altitude, double Latitude) { //Convert from degress to radians Azimuth = DegreesToRadians(Azimuth); Altitude = DegreesToRadians(Altitude); Latitude = DegreesToRadians(Latitude); AAS2DCoordinate Equatorial = new AAS2DCoordinate { X = RadiansToHours(Math.Atan2(Math.Sin(Azimuth), Math.Cos(Azimuth) * Math.Sin(Latitude) + Math.Tan(Altitude) * Math.Cos(Latitude))) }; if (Equatorial.X < 0) { Equatorial.X += 24; } Equatorial.Y = RadiansToDegrees(Math.Asin(Math.Sin(Latitude) * Math.Sin(Altitude) - Math.Cos(Latitude) * Math.Cos(Altitude) * Math.Cos(Azimuth))); return(Equatorial); }
//--------------- Processing Information ----------------------- void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) { string message = Encoding.Default.GetString(e.Message); Debug.Log(message); Debug.Log(e.Topic); //Debug.Log("Altitude is: " + pos.Altitude); //Debug.Log("Azimuth is: " + pos.Azimuth); if (e.Topic == "IC.embedded/friends/unity/sensors") { ReceivedTelescopePos pos = JsonUtility.FromJson <ReceivedTelescopePos>(message); Debug.Log("Altitude is: " + pos.Altitude); Debug.Log("Azimuth is: " + pos.Azimuth); OnReceivePosUpdate(pos); TelsecopeUpdate = message; } else if (e.Topic == "IC.embedded/friends/unity/camera") { PictureTaken pic = JsonUtility.FromJson <PictureTaken>(message); Debug.Log(pic.Altitude); Debug.Log(pic.Azimuth); Debug.Log(pic.DayTaken); Debug.Log(pic.HourTaken); AASharp.AAS2DCoordinate coor = CoordinateTransformation.ToCelestialCoordinates(pic.Latitude, pic.Longitude, pic.Azimuth, pic.Altitude); OnReceivePic(pic, (float)coor.Y, (float)coor.X); ImageUpdate = message; //create new image data ImageData newImageData = new ImageData((float)coor.Y, (float)coor.X, pic.YearTaken, pic.HourTaken, pic.MinuteTaken, pic.ImageName); ALL_IMAGES.Add(newImageData); SaveData(); } }
public static AAS2DCoordinate EquatorialAberration(double Alpha, double Delta, double JD, bool bHighPrecision) { //Convert to radians Alpha = AASCoordinateTransformation.DegreesToRadians(Alpha * 15); Delta = AASCoordinateTransformation.DegreesToRadians(Delta); double cosAlpha = Math.Cos(Alpha); double sinAlpha = Math.Sin(Alpha); double cosDelta = Math.Cos(Delta); double sinDelta = Math.Sin(Delta); AAS3DCoordinate velocity = EarthVelocity(JD, bHighPrecision); //What is the return value AAS2DCoordinate aberration = new AAS2DCoordinate { X = AASCoordinateTransformation.RadiansToHours((velocity.Y * cosAlpha - velocity.X * sinAlpha) / (17314463350.0 * cosDelta)), Y = AASCoordinateTransformation.RadiansToDegrees(-(((velocity.X * cosAlpha + velocity.Y * sinAlpha) * sinDelta - velocity.Z * cosDelta) / 17314463350.0)) }; return(aberration); }
public static AAS2DCoordinate Galactic2Equatorial(double l, double b) { l -= 123; l = DegreesToRadians(l); b = DegreesToRadians(b); AAS2DCoordinate Equatorial = new AAS2DCoordinate { X = RadiansToDegrees(Math.Atan2(Math.Sin(l), Math.Cos(l) * Math.Sin(DegreesToRadians(27.4)) - Math.Tan(b) * Math.Cos(DegreesToRadians(27.4)))) }; Equatorial.X += 12.25; if (Equatorial.X < 0) { Equatorial.X += 360; } Equatorial.X = DegreesToHours(Equatorial.X); Equatorial.Y = RadiansToDegrees(Math.Asin(Math.Sin(b) * Math.Sin(DegreesToRadians(27.4)) + Math.Cos(b) * Math.Cos(DegreesToRadians(27.4)) * Math.Cos(l))); return(Equatorial); }
public static AASPhysicalMoonDetails CalculateTopocentric(double JD, double Longitude, double Latitude) { //First convert to radians Longitude = AASCoordinateTransformation.DegreesToRadians(Longitude); Latitude = AASCoordinateTransformation.DegreesToRadians(Latitude); double Lambda = 0; double Beta = 0; double epsilon = 0; AAS2DCoordinate Equatorial = new AAS2DCoordinate(); AASPhysicalMoonDetails details = CalculateHelper(JD, ref Lambda, ref Beta, ref epsilon, ref Equatorial); double R = AASMoon.RadiusVector(JD); double pi = AASMoon.RadiusVectorToHorizontalParallax(R); double Alpha = AASCoordinateTransformation.HoursToRadians(Equatorial.X); double Delta = AASCoordinateTransformation.DegreesToRadians(Equatorial.Y); double AST = AASSidereal.ApparentGreenwichSiderealTime(JD); double H = AASCoordinateTransformation.HoursToRadians(AST) - Longitude - Alpha; double Q = Math.Atan2(Math.Cos(Latitude) * Math.Sin(H), Math.Cos(Delta) * Math.Sin(Latitude) - Math.Sin(Delta) * Math.Cos(Latitude) * Math.Cos(H)); double Z = Math.Acos(Math.Sin(Delta) * Math.Sin(Latitude) + Math.Cos(Delta) * Math.Cos(Latitude) * Math.Cos(H)); double pidash = pi * (Math.Sin(Z) + 0.0084 * Math.Sin(2 * Z)); double Prad = AASCoordinateTransformation.DegreesToRadians(details.P); double DeltaL = -pidash *Math.Sin(Q - Prad) / Math.Cos(AASCoordinateTransformation.DegreesToRadians(details.b)); details.l += DeltaL; double DeltaB = pidash * Math.Cos(Q - Prad); details.b += DeltaB; double DeltaP = DeltaL * Math.Sin(AASCoordinateTransformation.DegreesToRadians(details.b)) - pidash * Math.Sin(Q) * Math.Tan(Delta); details.P += DeltaP; return(details); }
public static AAS2DCoordinate EclipticAberration(double Lambda, double Beta, double JD) { //What is the return value AAS2DCoordinate aberration = new AAS2DCoordinate(); double T = (JD - 2451545) / 36525; double Tsquared = T * T; double e = 0.016708634 - 0.000042037 * T - 0.0000001267 * Tsquared; double pi = 102.93735 + 1.71946 * T + 0.00046 * Tsquared; const double k = 20.49552; double SunLongitude = AASSun.GeometricEclipticLongitude(JD); //Convert to radians pi = AASCoordinateTransformation.DegreesToRadians(pi); Lambda = AASCoordinateTransformation.DegreesToRadians(Lambda); Beta = AASCoordinateTransformation.DegreesToRadians(Beta); SunLongitude = AASCoordinateTransformation.DegreesToRadians(SunLongitude); aberration.X = (-k * Math.Cos(SunLongitude - Lambda) + e * k * Math.Cos(pi - Lambda)) / Math.Cos(Beta) / 3600; aberration.Y = -k *Math.Sin(Beta) * (Math.Sin(SunLongitude - Lambda) - e * Math.Sin(pi - Lambda)) / 3600; return(aberration); }
private static AASSaturnMoonsDetails CalculateHelper(double JD, double sunlongrad, double betarad, double R, bool bHighPrecision) { //What will be the return value AASSaturnMoonsDetails details = new AASSaturnMoonsDetails(); //Calculate the position of Saturn decreased by the light travel time from Saturn to the specified position double DELTA = 9; double PreviousLightTravelTime = 0; double LightTravelTime = AASElliptical.DistanceToLightTime(DELTA); double x = 0; double y = 0; double z = 0; double JD1 = JD - LightTravelTime; bool bIterate = true; while (bIterate) { //Calculate the position of Saturn double l = AASSaturn.EclipticLongitude(JD1, bHighPrecision); double lrad = AASCoordinateTransformation.DegreesToRadians(l); double b = AASSaturn.EclipticLatitude(JD1, bHighPrecision); double brad = AASCoordinateTransformation.DegreesToRadians(b); double r = AASSaturn.RadiusVector(JD1, bHighPrecision); x = r * Math.Cos(brad) * Math.Cos(lrad) + R * Math.Cos(sunlongrad); y = r * Math.Cos(brad) * Math.Sin(lrad) + R * Math.Sin(sunlongrad); z = r * Math.Sin(brad) + R * Math.Sin(betarad); DELTA = Math.Sqrt(x * x + y * y + z * z); LightTravelTime = AASElliptical.DistanceToLightTime(DELTA); //Prepare for the next loop around bIterate = (Math.Abs(LightTravelTime - PreviousLightTravelTime) > 2e-6); //2e-6 corresponds to 0.17 of a second if (bIterate) { JD1 = JD - LightTravelTime; PreviousLightTravelTime = LightTravelTime; } } //Calculate Saturn's Longitude and Latitude double lambda0 = Math.Atan2(y, x); lambda0 = AASCoordinateTransformation.RadiansToDegrees(lambda0); double beta0 = Math.Atan(z / Math.Sqrt(x * x + y * y)); beta0 = AASCoordinateTransformation.RadiansToDegrees(beta0); //Precess the longtitude and Latitutude to B1950.0 AAS2DCoordinate Saturn1950 = AASPrecession.PrecessEcliptic(lambda0, beta0, JD, 2433282.4235); lambda0 = Saturn1950.X; double lambda0rad = AASCoordinateTransformation.DegreesToRadians(lambda0); beta0 = Saturn1950.Y; double beta0rad = AASCoordinateTransformation.DegreesToRadians(beta0); double JDE = JD - LightTravelTime; double t1 = JDE - 2411093.0; double t2 = t1 / 365.25; double t3 = ((JDE - 2433282.423) / 365.25) + 1950.0; double t4 = JDE - 2411368.0; double t5 = t4 / 365.25; double t6 = JDE - 2415020.0; double t7 = t6 / 36525.0; double t8 = t6 / 365.25; double t9 = (JDE - 2442000.5) / 365.25; double t10 = JDE - 2409786.0; double t11 = t10 / 36525.0; double t112 = t11 * t11; double t113 = t112 * t11; double W0 = AASCoordinateTransformation.MapTo0To360Range(5.095 * (t3 - 1866.39)); double W0rad = AASCoordinateTransformation.DegreesToRadians(W0); double W1 = AASCoordinateTransformation.MapTo0To360Range(74.4 + 32.39 * t2); double W1rad = AASCoordinateTransformation.DegreesToRadians(W1); double W2 = AASCoordinateTransformation.MapTo0To360Range(134.3 + 92.62 * t2); double W2rad = AASCoordinateTransformation.DegreesToRadians(W2); double W3 = AASCoordinateTransformation.MapTo0To360Range(42.0 - 0.5118 * t5); double W3rad = AASCoordinateTransformation.DegreesToRadians(W3); double W4 = AASCoordinateTransformation.MapTo0To360Range(276.59 + 0.5118 * t5); double W4rad = AASCoordinateTransformation.DegreesToRadians(W4); double W5 = AASCoordinateTransformation.MapTo0To360Range(267.2635 + 1222.1136 * t7); double W5rad = AASCoordinateTransformation.DegreesToRadians(W5); double W6 = AASCoordinateTransformation.MapTo0To360Range(175.4762 + 1221.5515 * t7); double W6rad = AASCoordinateTransformation.DegreesToRadians(W6); double W7 = AASCoordinateTransformation.MapTo0To360Range(2.4891 + 0.002435 * t7); double W7rad = AASCoordinateTransformation.DegreesToRadians(W7); double W8 = AASCoordinateTransformation.MapTo0To360Range(113.35 - 0.2597 * t7); double W8rad = AASCoordinateTransformation.DegreesToRadians(W8); double s1 = Math.Sin(AASCoordinateTransformation.DegreesToRadians(28.0817)); double s2 = Math.Sin(AASCoordinateTransformation.DegreesToRadians(168.8112)); double c1 = Math.Cos(AASCoordinateTransformation.DegreesToRadians(28.0817)); double c2 = Math.Cos(AASCoordinateTransformation.DegreesToRadians(168.8112)); double e1 = 0.05589 - 0.000346 * t7; //Satellite 1 double L = AASCoordinateTransformation.MapTo0To360Range(127.64 + 381.994497 * t1 - 43.57 * Math.Sin(W0rad) - 0.720 * Math.Sin(3 * W0rad) - 0.02144 * Math.Sin(5 * W0rad)); double p = 106.1 + 365.549 * t2; double M = L - p; double Mrad = AASCoordinateTransformation.DegreesToRadians(M); double C = 2.18287 * Math.Sin(Mrad) + 0.025988 * Math.Sin(2 * Mrad) + 0.00043 * Math.Sin(3 * Mrad); double Crad = AASCoordinateTransformation.DegreesToRadians(C); double lambda1 = AASCoordinateTransformation.MapTo0To360Range(L + C); double r1 = 3.06879 / (1 + 0.01905 * Math.Cos(Mrad + Crad)); double gamma1 = 1.563; double omega1 = AASCoordinateTransformation.MapTo0To360Range(54.5 - 365.072 * t2); //Satellite 2 L = AASCoordinateTransformation.MapTo0To360Range(200.317 + 262.7319002 * t1 + 0.25667 * Math.Sin(W1rad) + 0.20883 * Math.Sin(W2rad)); p = 309.107 + 123.44121 * t2; M = L - p; Mrad = AASCoordinateTransformation.DegreesToRadians(M); C = 0.55577 * Math.Sin(Mrad) + 0.00168 * Math.Sin(2 * Mrad); Crad = AASCoordinateTransformation.DegreesToRadians(C); double lambda2 = AASCoordinateTransformation.MapTo0To360Range(L + C); double r2 = 3.94118 / (1 + 0.00485 * Math.Cos(Mrad + Crad)); double gamma2 = 0.0262; double omega2 = AASCoordinateTransformation.MapTo0To360Range(348 - 151.95 * t2); //Satellite 3 double lambda3 = AASCoordinateTransformation.MapTo0To360Range(285.306 + 190.69791226 * t1 + 2.063 * Math.Sin(W0rad) + 0.03409 * Math.Sin(3 * W0rad) + 0.001015 * Math.Sin(5 * W0rad)); double r3 = 4.880998; double gamma3 = 1.0976; double omega3 = AASCoordinateTransformation.MapTo0To360Range(111.33 - 72.2441 * t2); //Satellite 4 L = AASCoordinateTransformation.MapTo0To360Range(254.712 + 131.53493193 * t1 - 0.0215 * Math.Sin(W1rad) - 0.01733 * Math.Sin(W2rad)); p = 174.8 + 30.820 * t2; M = L - p; Mrad = AASCoordinateTransformation.DegreesToRadians(M); C = 0.24717 * Math.Sin(Mrad) + 0.00033 * Math.Sin(2 * Mrad); Crad = AASCoordinateTransformation.DegreesToRadians(C); double lambda4 = AASCoordinateTransformation.MapTo0To360Range(L + C); double r4 = 6.24871 / (1 + 0.002157 * Math.Cos(Mrad + Crad)); double gamma4 = 0.0139; double omega4 = AASCoordinateTransformation.MapTo0To360Range(232 - 30.27 * t2); //Satellite 5 double pdash = 342.7 + 10.057 * t2; double pdashrad = AASCoordinateTransformation.DegreesToRadians(pdash); double a1 = 0.000265 * Math.Sin(pdashrad) + 0.001 * Math.Sin(W4rad); //Note the book uses the incorrect constant 0.01*Math.Sin(W4rad); double a2 = 0.000265 * Math.Cos(pdashrad) + 0.001 * Math.Cos(W4rad); //Note the book uses the incorrect constant 0.01*cos(W4rad); double e = Math.Sqrt(a1 * a1 + a2 * a2); p = AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(a1, a2)); double N = 345 - 10.057 * t2; double Nrad = AASCoordinateTransformation.DegreesToRadians(N); double lambdadash = AASCoordinateTransformation.MapTo0To360Range(359.244 + 79.69004720 * t1 + 0.086754 * Math.Sin(Nrad)); double i = 28.0362 + 0.346898 * Math.Cos(Nrad) + 0.01930 * Math.Cos(W3rad); double omega = 168.8034 + 0.736936 * Math.Sin(Nrad) + 0.041 * Math.Sin(W3rad); double a = 8.725924; double lambda5 = 0; double gamma5 = 0; double omega5 = 0; double r5 = 0; HelperSubroutine(e, lambdadash, p, a, omega, i, c1, s1, ref r5, ref lambda5, ref gamma5, ref omega5); //Satellite 6 L = 261.1582 + 22.57697855 * t4 + 0.074025 * Math.Sin(W3rad); double idash = 27.45141 + 0.295999 * Math.Cos(W3rad); double idashrad = AASCoordinateTransformation.DegreesToRadians(idash); double omegadash = 168.66925 + 0.628808 * Math.Sin(W3rad); double omegadashrad = AASCoordinateTransformation.DegreesToRadians(omegadash); a1 = Math.Sin(W7rad) * Math.Sin(omegadashrad - W8rad); a2 = Math.Cos(W7rad) * Math.Sin(idashrad) - Math.Sin(W7rad) * Math.Cos(idashrad) * Math.Cos(omegadashrad - W8rad); double g0 = AASCoordinateTransformation.DegreesToRadians(102.8623); double psi = Math.Atan2(a1, a2); if (a2 < 0) { psi += AASCoordinateTransformation.PI(); } double psideg = AASCoordinateTransformation.RadiansToDegrees(psi); double s = Math.Sqrt(a1 * a1 + a2 * a2); double g = W4 - omegadash - psideg; double w_ = 0; for (int j = 0; j < 3; j++) { w_ = W4 + 0.37515 * (Math.Sin(2 * AASCoordinateTransformation.DegreesToRadians(g)) - Math.Sin(2 * g0)); g = w_ - omegadash - psideg; } double grad = AASCoordinateTransformation.DegreesToRadians(g); double edash = 0.029092 + 0.00019048 * (Math.Cos(2 * grad) - Math.Cos(2 * g0)); double q = AASCoordinateTransformation.DegreesToRadians(2 * (W5 - w_)); double b1 = Math.Sin(idashrad) * Math.Sin(omegadashrad - W8rad); double b2 = Math.Cos(W7rad) * Math.Sin(idashrad) * Math.Cos(omegadashrad - W8rad) - Math.Sin(W7rad) * Math.Cos(idashrad); double atanb1b2 = Math.Atan2(b1, b2); double theta = atanb1b2 + W8rad; e = edash + 0.002778797 * edash * Math.Cos(q); p = w_ + 0.159215 * Math.Sin(q); double u = 2 * W5rad - 2 * theta + psi; double h = 0.9375 * edash * edash * Math.Sin(q) + 0.1875 * s * s * Math.Sin(2 * (W5rad - theta)); lambdadash = AASCoordinateTransformation.MapTo0To360Range(L - 0.254744 * (e1 * Math.Sin(W6rad) + 0.75 * e1 * e1 * Math.Sin(2 * W6rad) + h)); i = idash + 0.031843 * s * Math.Cos(u); omega = omegadash + (0.031843 * s * Math.Sin(u)) / Math.Sin(idashrad); a = 20.216193; double lambda6 = 0; double gamma6 = 0; double omega6 = 0; double r6 = 0; HelperSubroutine(e, lambdadash, p, a, omega, i, c1, s1, ref r6, ref lambda6, ref gamma6, ref omega6); //Satellite 7 double eta = 92.39 + 0.5621071 * t6; double etarad = AASCoordinateTransformation.DegreesToRadians(eta); double zeta = 148.19 - 19.18 * t8; double zetarad = AASCoordinateTransformation.DegreesToRadians(zeta); theta = AASCoordinateTransformation.DegreesToRadians(184.8 - 35.41 * t9); double thetadash = theta - AASCoordinateTransformation.DegreesToRadians(7.5); double aS = AASCoordinateTransformation.DegreesToRadians(176 + 12.22 * t8); double bs = AASCoordinateTransformation.DegreesToRadians(8 + 24.44 * t8); double cs = bs + AASCoordinateTransformation.DegreesToRadians(5); w_ = 69.898 - 18.67088 * t8; double phi = 2 * (w_ - W5); double phirad = AASCoordinateTransformation.DegreesToRadians(phi); double chi = 94.9 - 2.292 * t8; double chirad = AASCoordinateTransformation.DegreesToRadians(chi); a = 24.50601 - 0.08686 * Math.Cos(etarad) - 0.00166 * Math.Cos(zetarad + etarad) + 0.00175 * Math.Cos(zetarad - etarad); e = 0.103458 - 0.004099 * Math.Cos(etarad) - 0.000167 * Math.Cos(zetarad + etarad) + 0.000235 * Math.Cos(zetarad - etarad) + 0.02303 * Math.Cos(zetarad) - 0.00212 * Math.Cos(2 * zetarad) + 0.000151 * Math.Cos(3 * zetarad) + 0.00013 * Math.Cos(phirad); p = w_ + 0.15648 * Math.Sin(chirad) - 0.4457 * Math.Sin(etarad) - 0.2657 * Math.Sin(zetarad + etarad) + -0.3573 * Math.Sin(zetarad - etarad) - 12.872 * Math.Sin(zetarad) + 1.668 * Math.Sin(2 * zetarad) + -0.2419 * Math.Sin(3 * zetarad) - 0.07 * Math.Sin(phirad); lambdadash = AASCoordinateTransformation.MapTo0To360Range(177.047 + 16.91993829 * t6 + 0.15648 * Math.Sin(chirad) + 9.142 * Math.Sin(etarad) + 0.007 * Math.Sin(2 * etarad) - 0.014 * Math.Sin(3 * etarad) + 0.2275 * Math.Sin(zetarad + etarad) + 0.2112 * Math.Sin(zetarad - etarad) - 0.26 * Math.Sin(zetarad) - 0.0098 * Math.Sin(2 * zetarad) + -0.013 * Math.Sin(aS) + 0.017 * Math.Sin(bs) - 0.0303 * Math.Sin(phirad)); i = 27.3347 + 0.643486 * Math.Cos(chirad) + 0.315 * Math.Cos(W3rad) + 0.018 * Math.Cos(theta) - 0.018 * Math.Cos(cs); omega = 168.6812 + 1.40136 * Math.Cos(chirad) + 0.68599 * Math.Sin(W3rad) - 0.0392 * Math.Sin(cs) + 0.0366 * Math.Sin(thetadash); double lambda7 = 0; double gamma7 = 0; double omega7 = 0; double r7 = 0; HelperSubroutine(e, lambdadash, p, a, omega, i, c1, s1, ref r7, ref lambda7, ref gamma7, ref omega7); //Satellite 8 L = AASCoordinateTransformation.MapTo0To360Range(261.1582 + 22.57697855 * t4); double w_dash = 91.796 + 0.562 * t7; psi = 4.367 - 0.195 * t7; double psirad = AASCoordinateTransformation.DegreesToRadians(psi); theta = 146.819 - 3.198 * t7; phi = 60.470 + 1.521 * t7; phirad = AASCoordinateTransformation.DegreesToRadians(phi); double PHI = 205.055 - 2.091 * t7; edash = 0.028298 + 0.001156 * t11; double w_0 = 352.91 + 11.71 * t11; double mu = AASCoordinateTransformation.MapTo0To360Range(76.3852 + 4.53795125 * t10); idash = 18.4602 - 0.9518 * t11 - 0.072 * t112 + 0.0054 * t113; idashrad = AASCoordinateTransformation.DegreesToRadians(idash); omegadash = 143.198 - 3.919 * t11 + 0.116 * t112 + 0.008 * t113; double _l = AASCoordinateTransformation.DegreesToRadians(mu - w_0); g = AASCoordinateTransformation.DegreesToRadians(w_0 - omegadash - psi); double g1 = AASCoordinateTransformation.DegreesToRadians(w_0 - omegadash - phi); double ls = AASCoordinateTransformation.DegreesToRadians(W5 - w_dash); double gs = AASCoordinateTransformation.DegreesToRadians(w_dash - theta); double lt = AASCoordinateTransformation.DegreesToRadians(L - W4); double gt = AASCoordinateTransformation.DegreesToRadians(W4 - PHI); double u1 = 2 * (_l + g - ls - gs); double u2 = _l + g1 - lt - gt; double u3 = _l + 2 * (g - ls - gs); double u4 = lt + gt - g1; double u5 = 2 * (ls + gs); a = 58.935028 + 0.004638 * Math.Cos(u1) + 0.058222 * Math.Cos(u2); e = edash - 0.0014097 * Math.Cos(g1 - gt) + 0.0003733 * Math.Cos(u5 - 2 * g) + 0.0001180 * Math.Cos(u3) + 0.0002408 * Math.Cos(_l) + 0.0002849 * Math.Cos(_l + u2) + 0.0006190 * Math.Cos(u4); double w = 0.08077 * Math.Sin(g1 - gt) + 0.02139 * Math.Sin(u5 - 2 * g) - 0.00676 * Math.Sin(u3) + 0.01380 * Math.Sin(_l) + 0.01632 * Math.Sin(_l + u2) + 0.03547 * Math.Sin(u4); p = w_0 + w / edash; lambdadash = mu - 0.04299 * Math.Sin(u2) - 0.00789 * Math.Sin(u1) - 0.06312 * Math.Sin(ls) + -0.00295 * Math.Sin(2 * ls) - 0.02231 * Math.Sin(u5) + 0.00650 * Math.Sin(u5 + psirad); i = idash + 0.04204 * Math.Cos(u5 + psirad) + 0.00235 * Math.Cos(_l + g1 + lt + gt + phirad) + 0.00360 * Math.Cos(u2 + phirad); double wdash = 0.04204 * Math.Sin(u5 + psirad) + 0.00235 * Math.Sin(_l + g1 + lt + gt + phirad) + 0.00358 * Math.Sin(u2 + phirad); omega = omegadash + wdash / Math.Sin(idashrad); double lambda8 = 0; double gamma8 = 0; double omega8 = 0; double r8 = 0; HelperSubroutine(e, lambdadash, p, a, omega, i, c1, s1, ref r8, ref lambda8, ref gamma8, ref omega8); u = AASCoordinateTransformation.DegreesToRadians(lambda1 - omega1); w = AASCoordinateTransformation.DegreesToRadians(omega1 - 168.8112); double gamma1rad = AASCoordinateTransformation.DegreesToRadians(gamma1); double X1 = r1 * (Math.Cos(u) * Math.Cos(w) - Math.Sin(u) * Math.Cos(gamma1rad) * Math.Sin(w)); double Y1 = r1 * (Math.Sin(u) * Math.Cos(w) * Math.Cos(gamma1rad) + Math.Cos(u) * Math.Sin(w)); double Z1 = r1 * Math.Sin(u) * Math.Sin(gamma1rad); u = AASCoordinateTransformation.DegreesToRadians(lambda2 - omega2); w = AASCoordinateTransformation.DegreesToRadians(omega2 - 168.8112); double gamma2rad = AASCoordinateTransformation.DegreesToRadians(gamma2); double X2 = r2 * (Math.Cos(u) * Math.Cos(w) - Math.Sin(u) * Math.Cos(gamma2rad) * Math.Sin(w)); double Y2 = r2 * (Math.Sin(u) * Math.Cos(w) * Math.Cos(gamma2rad) + Math.Cos(u) * Math.Sin(w)); double Z2 = r2 * Math.Sin(u) * Math.Sin(gamma2rad); u = AASCoordinateTransformation.DegreesToRadians(lambda3 - omega3); w = AASCoordinateTransformation.DegreesToRadians(omega3 - 168.8112); double gamma3rad = AASCoordinateTransformation.DegreesToRadians(gamma3); double X3 = r3 * (Math.Cos(u) * Math.Cos(w) - Math.Sin(u) * Math.Cos(gamma3rad) * Math.Sin(w)); double Y3 = r3 * (Math.Sin(u) * Math.Cos(w) * Math.Cos(gamma3rad) + Math.Cos(u) * Math.Sin(w)); double Z3 = r3 * Math.Sin(u) * Math.Sin(gamma3rad); u = AASCoordinateTransformation.DegreesToRadians(lambda4 - omega4); w = AASCoordinateTransformation.DegreesToRadians(omega4 - 168.8112); double gamma4rad = AASCoordinateTransformation.DegreesToRadians(gamma4); double X4 = r4 * (Math.Cos(u) * Math.Cos(w) - Math.Sin(u) * Math.Cos(gamma4rad) * Math.Sin(w)); double Y4 = r4 * (Math.Sin(u) * Math.Cos(w) * Math.Cos(gamma4rad) + Math.Cos(u) * Math.Sin(w)); double Z4 = r4 * Math.Sin(u) * Math.Sin(gamma4rad); u = AASCoordinateTransformation.DegreesToRadians(lambda5 - omega5); w = AASCoordinateTransformation.DegreesToRadians(omega5 - 168.8112); double gamma5rad = AASCoordinateTransformation.DegreesToRadians(gamma5); double X5 = r5 * (Math.Cos(u) * Math.Cos(w) - Math.Sin(u) * Math.Cos(gamma5rad) * Math.Sin(w)); double Y5 = r5 * (Math.Sin(u) * Math.Cos(w) * Math.Cos(gamma5rad) + Math.Cos(u) * Math.Sin(w)); double Z5 = r5 * Math.Sin(u) * Math.Sin(gamma5rad); u = AASCoordinateTransformation.DegreesToRadians(lambda6 - omega6); w = AASCoordinateTransformation.DegreesToRadians(omega6 - 168.8112); double gamma6rad = AASCoordinateTransformation.DegreesToRadians(gamma6); double X6 = r6 * (Math.Cos(u) * Math.Cos(w) - Math.Sin(u) * Math.Cos(gamma6rad) * Math.Sin(w)); double Y6 = r6 * (Math.Sin(u) * Math.Cos(w) * Math.Cos(gamma6rad) + Math.Cos(u) * Math.Sin(w)); double Z6 = r6 * Math.Sin(u) * Math.Sin(gamma6rad); u = AASCoordinateTransformation.DegreesToRadians(lambda7 - omega7); w = AASCoordinateTransformation.DegreesToRadians(omega7 - 168.8112); double gamma7rad = AASCoordinateTransformation.DegreesToRadians(gamma7); double X7 = r7 * (Math.Cos(u) * Math.Cos(w) - Math.Sin(u) * Math.Cos(gamma7rad) * Math.Sin(w)); double Y7 = r7 * (Math.Sin(u) * Math.Cos(w) * Math.Cos(gamma7rad) + Math.Cos(u) * Math.Sin(w)); double Z7 = r7 * Math.Sin(u) * Math.Sin(gamma7rad); u = AASCoordinateTransformation.DegreesToRadians(lambda8 - omega8); w = AASCoordinateTransformation.DegreesToRadians(omega8 - 168.8112); double gamma8rad = AASCoordinateTransformation.DegreesToRadians(gamma8); double X8 = r8 * (Math.Cos(u) * Math.Cos(w) - Math.Sin(u) * Math.Cos(gamma8rad) * Math.Sin(w)); double Y8 = r8 * (Math.Sin(u) * Math.Cos(w) * Math.Cos(gamma8rad) + Math.Cos(u) * Math.Sin(w)); double Z8 = r8 * Math.Sin(u) * Math.Sin(gamma8rad); double X9 = 0; double Y9 = 0; double Z9 = 1; //Now do the rotations, first for the ficticious 9th satellite, so that we can calculate D double A4 = 0; double B4 = 0; double C4 = 0; Rotations(X9, Y9, Z9, c1, s1, c2, s2, lambda0rad, beta0rad, ref A4, ref B4, ref C4); double D = Math.Atan2(A4, C4); //Now calculate the values for satellite 1 Rotations(X1, Y1, Z1, c1, s1, c2, s2, lambda0rad, beta0rad, ref A4, ref B4, ref C4); details.Satellite1.TrueRectangularCoordinates.X = A4 * Math.Cos(D) - C4 * Math.Sin(D); details.Satellite1.TrueRectangularCoordinates.Y = A4 * Math.Sin(D) + C4 * Math.Cos(D); details.Satellite1.TrueRectangularCoordinates.Z = B4; //Now calculate the values for satellite 2 Rotations(X2, Y2, Z2, c1, s1, c2, s2, lambda0rad, beta0rad, ref A4, ref B4, ref C4); details.Satellite2.TrueRectangularCoordinates.X = A4 * Math.Cos(D) - C4 * Math.Sin(D); details.Satellite2.TrueRectangularCoordinates.Y = A4 * Math.Sin(D) + C4 * Math.Cos(D); details.Satellite2.TrueRectangularCoordinates.Z = B4; //Now calculate the values for satellite 3 Rotations(X3, Y3, Z3, c1, s1, c2, s2, lambda0rad, beta0rad, ref A4, ref B4, ref C4); details.Satellite3.TrueRectangularCoordinates.X = A4 * Math.Cos(D) - C4 * Math.Sin(D); details.Satellite3.TrueRectangularCoordinates.Y = A4 * Math.Sin(D) + C4 * Math.Cos(D); details.Satellite3.TrueRectangularCoordinates.Z = B4; //Now calculate the values for satellite 4 Rotations(X4, Y4, Z4, c1, s1, c2, s2, lambda0rad, beta0rad, ref A4, ref B4, ref C4); details.Satellite4.TrueRectangularCoordinates.X = A4 * Math.Cos(D) - C4 * Math.Sin(D); details.Satellite4.TrueRectangularCoordinates.Y = A4 * Math.Sin(D) + C4 * Math.Cos(D); details.Satellite4.TrueRectangularCoordinates.Z = B4; //Now calculate the values for satellite 5 Rotations(X5, Y5, Z5, c1, s1, c2, s2, lambda0rad, beta0rad, ref A4, ref B4, ref C4); details.Satellite5.TrueRectangularCoordinates.X = A4 * Math.Cos(D) - C4 * Math.Sin(D); details.Satellite5.TrueRectangularCoordinates.Y = A4 * Math.Sin(D) + C4 * Math.Cos(D); details.Satellite5.TrueRectangularCoordinates.Z = B4; //Now calculate the values for satellite 6 Rotations(X6, Y6, Z6, c1, s1, c2, s2, lambda0rad, beta0rad, ref A4, ref B4, ref C4); details.Satellite6.TrueRectangularCoordinates.X = A4 * Math.Cos(D) - C4 * Math.Sin(D); details.Satellite6.TrueRectangularCoordinates.Y = A4 * Math.Sin(D) + C4 * Math.Cos(D); details.Satellite6.TrueRectangularCoordinates.Z = B4; //Now calculate the values for satellite 7 Rotations(X7, Y7, Z7, c1, s1, c2, s2, lambda0rad, beta0rad, ref A4, ref B4, ref C4); details.Satellite7.TrueRectangularCoordinates.X = A4 * Math.Cos(D) - C4 * Math.Sin(D); details.Satellite7.TrueRectangularCoordinates.Y = A4 * Math.Sin(D) + C4 * Math.Cos(D); details.Satellite7.TrueRectangularCoordinates.Z = B4; //Now calculate the values for satellite 8 Rotations(X8, Y8, Z8, c1, s1, c2, s2, lambda0rad, beta0rad, ref A4, ref B4, ref C4); details.Satellite8.TrueRectangularCoordinates.X = A4 * Math.Cos(D) - C4 * Math.Sin(D); details.Satellite8.TrueRectangularCoordinates.Y = A4 * Math.Sin(D) + C4 * Math.Cos(D); details.Satellite8.TrueRectangularCoordinates.Z = B4; //apply the differential light-time correction details.Satellite1.ApparentRectangularCoordinates.X = details.Satellite1.TrueRectangularCoordinates.X + Math.Abs(details.Satellite1.TrueRectangularCoordinates.Z) / 20947 * Math.Sqrt(1 - (details.Satellite1.TrueRectangularCoordinates.X / r1) * (details.Satellite1.TrueRectangularCoordinates.X / r1)); details.Satellite1.ApparentRectangularCoordinates.Y = details.Satellite1.TrueRectangularCoordinates.Y; details.Satellite1.ApparentRectangularCoordinates.Z = details.Satellite1.TrueRectangularCoordinates.Z; details.Satellite2.ApparentRectangularCoordinates.X = details.Satellite2.TrueRectangularCoordinates.X + Math.Abs(details.Satellite2.TrueRectangularCoordinates.Z) / 23715 * Math.Sqrt(1 - (details.Satellite2.TrueRectangularCoordinates.X / r2) * (details.Satellite2.TrueRectangularCoordinates.X / r2)); details.Satellite2.ApparentRectangularCoordinates.Y = details.Satellite2.TrueRectangularCoordinates.Y; details.Satellite2.ApparentRectangularCoordinates.Z = details.Satellite2.TrueRectangularCoordinates.Z; details.Satellite3.ApparentRectangularCoordinates.X = details.Satellite3.TrueRectangularCoordinates.X + Math.Abs(details.Satellite3.TrueRectangularCoordinates.Z) / 26382 * Math.Sqrt(1 - (details.Satellite3.TrueRectangularCoordinates.X / r3) * (details.Satellite3.TrueRectangularCoordinates.X / r3)); details.Satellite3.ApparentRectangularCoordinates.Y = details.Satellite3.TrueRectangularCoordinates.Y; details.Satellite3.ApparentRectangularCoordinates.Z = details.Satellite3.TrueRectangularCoordinates.Z; details.Satellite4.ApparentRectangularCoordinates.X = details.Satellite4.TrueRectangularCoordinates.X + Math.Abs(details.Satellite4.TrueRectangularCoordinates.Z) / 29876 * Math.Sqrt(1 - (details.Satellite4.TrueRectangularCoordinates.X / r4) * (details.Satellite4.TrueRectangularCoordinates.X / r4)); details.Satellite4.ApparentRectangularCoordinates.Y = details.Satellite4.TrueRectangularCoordinates.Y; details.Satellite4.ApparentRectangularCoordinates.Z = details.Satellite4.TrueRectangularCoordinates.Z; details.Satellite5.ApparentRectangularCoordinates.X = details.Satellite5.TrueRectangularCoordinates.X + Math.Abs(details.Satellite5.TrueRectangularCoordinates.Z) / 35313 * Math.Sqrt(1 - (details.Satellite5.TrueRectangularCoordinates.X / r5) * (details.Satellite5.TrueRectangularCoordinates.X / r5)); details.Satellite5.ApparentRectangularCoordinates.Y = details.Satellite5.TrueRectangularCoordinates.Y; details.Satellite5.ApparentRectangularCoordinates.Z = details.Satellite5.TrueRectangularCoordinates.Z; details.Satellite6.ApparentRectangularCoordinates.X = details.Satellite6.TrueRectangularCoordinates.X + Math.Abs(details.Satellite6.TrueRectangularCoordinates.Z) / 53800 * Math.Sqrt(1 - (details.Satellite6.TrueRectangularCoordinates.X / r6) * (details.Satellite6.TrueRectangularCoordinates.X / r6)); details.Satellite6.ApparentRectangularCoordinates.Y = details.Satellite6.TrueRectangularCoordinates.Y; details.Satellite6.ApparentRectangularCoordinates.Z = details.Satellite6.TrueRectangularCoordinates.Z; details.Satellite7.ApparentRectangularCoordinates.X = details.Satellite7.TrueRectangularCoordinates.X + Math.Abs(details.Satellite7.TrueRectangularCoordinates.Z) / 59222 * Math.Sqrt(1 - (details.Satellite7.TrueRectangularCoordinates.X / r7) * (details.Satellite7.TrueRectangularCoordinates.X / r7)); details.Satellite7.ApparentRectangularCoordinates.Y = details.Satellite7.TrueRectangularCoordinates.Y; details.Satellite7.ApparentRectangularCoordinates.Z = details.Satellite7.TrueRectangularCoordinates.Z; details.Satellite8.ApparentRectangularCoordinates.X = details.Satellite8.TrueRectangularCoordinates.X + Math.Abs(details.Satellite8.TrueRectangularCoordinates.Z) / 91820 * Math.Sqrt(1 - (details.Satellite8.TrueRectangularCoordinates.X / r8) * (details.Satellite8.TrueRectangularCoordinates.X / r8)); details.Satellite8.ApparentRectangularCoordinates.Y = details.Satellite8.TrueRectangularCoordinates.Y; details.Satellite8.ApparentRectangularCoordinates.Z = details.Satellite8.TrueRectangularCoordinates.Z; //apply the perspective effect correction double W = DELTA / (DELTA + details.Satellite1.TrueRectangularCoordinates.Z / 2475); details.Satellite1.ApparentRectangularCoordinates.X *= W; details.Satellite1.ApparentRectangularCoordinates.Y *= W; W = DELTA / (DELTA + details.Satellite2.TrueRectangularCoordinates.Z / 2475); details.Satellite2.ApparentRectangularCoordinates.X *= W; details.Satellite2.ApparentRectangularCoordinates.Y *= W; W = DELTA / (DELTA + details.Satellite3.TrueRectangularCoordinates.Z / 2475); details.Satellite3.ApparentRectangularCoordinates.X *= W; details.Satellite3.ApparentRectangularCoordinates.Y *= W; W = DELTA / (DELTA + details.Satellite4.TrueRectangularCoordinates.Z / 2475); details.Satellite4.ApparentRectangularCoordinates.X *= W; details.Satellite4.ApparentRectangularCoordinates.Y *= W; W = DELTA / (DELTA + details.Satellite5.TrueRectangularCoordinates.Z / 2475); details.Satellite5.ApparentRectangularCoordinates.X *= W; details.Satellite5.ApparentRectangularCoordinates.Y *= W; W = DELTA / (DELTA + details.Satellite6.TrueRectangularCoordinates.Z / 2475); details.Satellite6.ApparentRectangularCoordinates.X *= W; details.Satellite6.ApparentRectangularCoordinates.Y *= W; W = DELTA / (DELTA + details.Satellite7.TrueRectangularCoordinates.Z / 2475); details.Satellite7.ApparentRectangularCoordinates.X *= W; details.Satellite7.ApparentRectangularCoordinates.Y *= W; W = DELTA / (DELTA + details.Satellite8.TrueRectangularCoordinates.Z / 2475); details.Satellite8.ApparentRectangularCoordinates.X *= W; details.Satellite8.ApparentRectangularCoordinates.Y *= W; return(details); }
public static AASEllipticalPlanetaryDetails Calculate(double JD, AASEllipticalObject ellipticalObject, bool bHighPrecision) { //What will the the return value AASEllipticalPlanetaryDetails details = new AASEllipticalPlanetaryDetails(); //Calculate the position of the earth first double JD0 = JD; double L0 = AASEarth.EclipticLongitude(JD0, bHighPrecision); double B0 = AASEarth.EclipticLatitude(JD0, bHighPrecision); double R0 = AASEarth.RadiusVector(JD0, bHighPrecision); L0 = AASCoordinateTransformation.DegreesToRadians(L0); B0 = AASCoordinateTransformation.DegreesToRadians(B0); double cosB0 = Math.Cos(B0); //Iterate to find the positions adjusting for light-time correction if required double L = 0; double B = 0; double R = 0; if (ellipticalObject != AASEllipticalObject.SUN) { bool bRecalc = true; bool bFirstRecalc = true; double LPrevious = 0; double BPrevious = 0; double RPrevious = 0; while (bRecalc) { switch (ellipticalObject) { case AASEllipticalObject.SUN: L = AASSun.GeometricEclipticLongitude(JD0, bHighPrecision); B = AASSun.GeometricEclipticLatitude(JD0, bHighPrecision); R = AASEarth.RadiusVector(JD0, bHighPrecision); break; case AASEllipticalObject.MERCURY: L = AASMercury.EclipticLongitude(JD0, bHighPrecision); B = AASMercury.EclipticLatitude(JD0, bHighPrecision); R = AASMercury.RadiusVector(JD0, bHighPrecision); break; case AASEllipticalObject.VENUS: L = AASVenus.EclipticLongitude(JD0, bHighPrecision); B = AASVenus.EclipticLatitude(JD0, bHighPrecision); R = AASVenus.RadiusVector(JD0, bHighPrecision); break; case AASEllipticalObject.MARS: L = AASMars.EclipticLongitude(JD0, bHighPrecision); B = AASMars.EclipticLatitude(JD0, bHighPrecision); R = AASMars.RadiusVector(JD0, bHighPrecision); break; case AASEllipticalObject.JUPITER: L = AASJupiter.EclipticLongitude(JD0, bHighPrecision); B = AASJupiter.EclipticLatitude(JD0, bHighPrecision); R = AASJupiter.RadiusVector(JD0, bHighPrecision); break; case AASEllipticalObject.SATURN: L = AASSaturn.EclipticLongitude(JD0, bHighPrecision); B = AASSaturn.EclipticLatitude(JD0, bHighPrecision); R = AASSaturn.RadiusVector(JD0, bHighPrecision); break; case AASEllipticalObject.URANUS: L = AASUranus.EclipticLongitude(JD0, bHighPrecision); B = AASUranus.EclipticLatitude(JD0, bHighPrecision); R = AASUranus.RadiusVector(JD0, bHighPrecision); break; case AASEllipticalObject.NEPTUNE: L = AASNeptune.EclipticLongitude(JD0, bHighPrecision); B = AASNeptune.EclipticLatitude(JD0, bHighPrecision); R = AASNeptune.RadiusVector(JD0, bHighPrecision); break; case AASEllipticalObject.PLUTO: L = AASPluto.EclipticLongitude(JD0); B = AASPluto.EclipticLatitude(JD0); R = AASPluto.RadiusVector(JD0); break; default: 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 Lrad = AASCoordinateTransformation.DegreesToRadians(L); double Brad = AASCoordinateTransformation.DegreesToRadians(B); double cosB = Math.Cos(Brad); double cosL = Math.Cos(Lrad); double x1 = R * cosB * cosL - R0 * cosB0 * Math.Cos(L0); double y1 = R * cosB * Math.Sin(Lrad) - R0 * cosB0 * Math.Sin(L0); double z1 = R * Math.Sin(Brad) - R0 * Math.Sin(B0); double distance = Math.Sqrt(x1 * x1 + y1 * y1 + z1 * z1); //Prepare for the next loop around JD0 = JD - AASElliptical.DistanceToLightTime(distance); } } } double x = 0; double y = 0; double z = 0; if (ellipticalObject != AASEllipticalObject.SUN) { double Lrad = AASCoordinateTransformation.DegreesToRadians(L); double Brad = AASCoordinateTransformation.DegreesToRadians(B); double cosB = Math.Cos(Brad); double 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); } else { x = -R0 *cosB0 *Math.Cos(L0); y = -R0 *cosB0 *Math.Sin(L0); z = -R0 *Math.Sin(B0); } double x2 = x * x; double y2 = y * y; details.ApparentGeocentricLatitude = AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(z, Math.Sqrt(x2 + y2))); details.ApparentGeocentricDistance = Math.Sqrt(x2 + y2 + z * z); details.ApparentGeocentricLongitude = AASCoordinateTransformation.MapTo0To360Range(AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(y, x))); details.ApparentLightTime = AASElliptical.DistanceToLightTime(details.ApparentGeocentricDistance); //Adjust for Aberration AAS2DCoordinate Aberration = AASAberration.EclipticAberration(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, JD, bHighPrecision); details.ApparentGeocentricLongitude += Aberration.X; details.ApparentGeocentricLatitude += Aberration.Y; //convert to the FK5 system double DeltaLong = AASFK5.CorrectionInLongitude(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, JD); details.ApparentGeocentricLatitude += AASFK5.CorrectionInLatitude(details.ApparentGeocentricLongitude, JD); details.ApparentGeocentricLongitude += DeltaLong; //Correct for nutation double NutationInLongitude = AASNutation.NutationInLongitude(JD); double Epsilon = AASNutation.TrueObliquityOfEcliptic(JD); details.ApparentGeocentricLongitude += AASCoordinateTransformation.DMSToDegrees(0, 0, NutationInLongitude); //Convert to RA and Dec AAS2DCoordinate ApparentEqu = AASCoordinateTransformation.Ecliptic2Equatorial(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, Epsilon); details.ApparentGeocentricRA = ApparentEqu.X; details.ApparentGeocentricDeclination = ApparentEqu.Y; return(details); }
public static AASPhysicalMoonDetails CalculateHelper(double JD, ref double Lambda, ref double Beta, ref double epsilon, ref AAS2DCoordinate Equatorial) { //What will be the return value AASPhysicalMoonDetails details = new AASPhysicalMoonDetails(); //Calculate the initial quantities Lambda = AASMoon.EclipticLongitude(JD); Beta = AASMoon.EclipticLatitude(JD); //Calculate the optical libration double omega = 0; double DeltaU = 0; double sigma = 0; double I = 0; double rho = 0; double ldash = 0; double bdash = 0; double ldash2 = 0; double bdash2 = 0; CalculateOpticalLibration(JD, Lambda, Beta, ref ldash, ref bdash, ref ldash2, ref bdash2, ref epsilon, ref omega, ref DeltaU, ref sigma, ref I, ref rho); details.ldash = ldash; details.bdash = bdash; details.ldash2 = ldash2; details.bdash2 = bdash2; double epsilonrad = AASCoordinateTransformation.DegreesToRadians(epsilon); //Calculate the total libration details.l = details.ldash + details.ldash2; details.b = details.bdash + details.bdash2; double b = AASCoordinateTransformation.DegreesToRadians(details.b); //Calculate the position angle double V = omega + DeltaU + AASCoordinateTransformation.DegreesToRadians(sigma) / Math.Sin(I); double I_rho = I + AASCoordinateTransformation.DegreesToRadians(rho); double X = Math.Sin(I_rho) * Math.Sin(V); double Y = Math.Sin(I_rho) * Math.Cos(V) * Math.Cos(epsilonrad) - Math.Cos(I_rho) * Math.Sin(epsilonrad); double w = Math.Atan2(X, Y); Equatorial = AASCoordinateTransformation.Ecliptic2Equatorial(Lambda, Beta, epsilon); double Alpha = AASCoordinateTransformation.HoursToRadians(Equatorial.X); details.P = AASCoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sqrt(X * X + Y * Y) * Math.Cos(Alpha - w) / (Math.Cos(b)))); return(details); }
public static AASSaturnRingDetails Calculate(double JD, bool bHighPrecision) { //What will be the return value AASSaturnRingDetails details = new AASSaturnRingDetails(); double T = (JD - 2451545) / 36525; double T2 = T * T; //Step 1. Calculate the inclination of the plane of the ring and the longitude of the ascending node referred to the ecliptic and mean equinox of the date double i = 28.075216 - 0.012998 * T + 0.000004 * T2; double irad = AASCoordinateTransformation.DegreesToRadians(i); double omega = 169.508470 + 1.394681 * T + 0.000412 * T2; double omegarad = AASCoordinateTransformation.DegreesToRadians(omega); //Step 2. Calculate the heliocentric longitude, latitude and radius vector of the Earth in the FK5 system double l0 = AASEarth.EclipticLongitude(JD, bHighPrecision); double b0 = AASEarth.EclipticLatitude(JD, bHighPrecision); l0 += AASFK5.CorrectionInLongitude(l0, b0, JD); double l0rad = AASCoordinateTransformation.DegreesToRadians(l0); b0 += AASFK5.CorrectionInLatitude(l0, JD); double b0rad = AASCoordinateTransformation.DegreesToRadians(b0); double R = AASEarth.RadiusVector(JD, bHighPrecision); //Step 3. Calculate the corresponding coordinates l,b,r for Saturn but for the instance t-lightraveltime double DELTA = 9; double PreviousEarthLightTravelTime = 0; double EarthLightTravelTime = AASElliptical.DistanceToLightTime(DELTA); double JD1 = JD - EarthLightTravelTime; bool bIterate = true; double x = 0; double y = 0; double z = 0; double l = 0; double b = 0; double r = 0; while (bIterate) { //Calculate the position of Saturn l = AASSaturn.EclipticLongitude(JD1, bHighPrecision); b = AASSaturn.EclipticLatitude(JD1, bHighPrecision); l += AASFK5.CorrectionInLongitude(l, b, JD1); b += AASFK5.CorrectionInLatitude(l, JD1); double lrad = AASCoordinateTransformation.DegreesToRadians(l); double brad = AASCoordinateTransformation.DegreesToRadians(b); r = AASSaturn.RadiusVector(JD1, bHighPrecision); //Step 4 x = r * Math.Cos(brad) * Math.Cos(lrad) - R * Math.Cos(l0rad); y = r * Math.Cos(brad) * Math.Sin(lrad) - R * Math.Sin(l0rad); z = r * Math.Sin(brad) - R * Math.Sin(b0rad); DELTA = Math.Sqrt(x * x + y * y + z * z); EarthLightTravelTime = AASElliptical.DistanceToLightTime(DELTA); //Prepare for the next loop around bIterate = (Math.Abs(EarthLightTravelTime - PreviousEarthLightTravelTime) > 2e-6); //2e-6 corresponds to 0.17 of a second if (bIterate) { JD1 = JD - EarthLightTravelTime; PreviousEarthLightTravelTime = EarthLightTravelTime; } } //Step 5. Calculate Saturn's geocentric Longitude and Latitude double lambda = Math.Atan2(y, x); double beta = Math.Atan2(z, Math.Sqrt(x * x + y * y)); //Step 6. Calculate B, a and b details.B = Math.Asin(Math.Sin(irad) * Math.Cos(beta) * Math.Sin(lambda - omegarad) - Math.Cos(irad) * Math.Sin(beta)); details.a = 375.35 / DELTA; details.b = details.a * Math.Sin(Math.Abs(details.B)); details.B = AASCoordinateTransformation.RadiansToDegrees(details.B); //Step 7. Calculate the longitude of the ascending node of Saturn's orbit double N = 113.6655 + 0.8771 * T; double Nrad = AASCoordinateTransformation.DegreesToRadians(N); double ldash = l - 0.01759 / r; double ldashrad = AASCoordinateTransformation.DegreesToRadians(ldash); double bdash = b - 0.000764 * Math.Cos(ldashrad - Nrad) / r; double bdashrad = AASCoordinateTransformation.DegreesToRadians(bdash); //Step 8. Calculate Bdash details.Bdash = AASCoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sin(irad) * Math.Cos(bdashrad) * Math.Sin(ldashrad - omegarad) - Math.Cos(irad) * Math.Sin(bdashrad))); //Step 9. Calculate DeltaU details.U1 = AASCoordinateTransformation.MapTo0To360Range(AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(Math.Sin(irad) * Math.Sin(bdashrad) + Math.Cos(irad) * Math.Cos(bdashrad) * Math.Sin(ldashrad - omegarad), Math.Cos(bdashrad) * Math.Cos(ldashrad - omegarad)))); details.U2 = AASCoordinateTransformation.MapTo0To360Range(AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(Math.Sin(irad) * Math.Sin(beta) + Math.Cos(irad) * Math.Cos(beta) * Math.Sin(lambda - omegarad), Math.Cos(beta) * Math.Cos(lambda - omegarad)))); details.DeltaU = Math.Abs(details.U1 - details.U2); if (details.DeltaU > 180) { details.DeltaU = 360 - details.DeltaU; } //Step 10. Calculate the Nutations double Obliquity = AASNutation.TrueObliquityOfEcliptic(JD); double NutationInLongitude = AASNutation.NutationInLongitude(JD); //Step 11. Calculate the Ecliptical longitude and latitude of the northern pole of the ring plane double lambda0 = omega - 90; double beta0 = 90 - i; //Step 12. Correct lambda and beta for the aberration of Saturn lambda += AASCoordinateTransformation.DegreesToRadians(0.005693 * Math.Cos(l0rad - lambda) / Math.Cos(beta)); beta += AASCoordinateTransformation.DegreesToRadians(0.005693 * Math.Sin(l0rad - lambda) * Math.Sin(beta)); //Step 13. Add nutation in longitude to lambda0 and lambda lambda = AASCoordinateTransformation.RadiansToDegrees(lambda); lambda += NutationInLongitude / 3600; lambda = AASCoordinateTransformation.MapTo0To360Range(lambda); lambda0 += NutationInLongitude / 3600; lambda0 = AASCoordinateTransformation.MapTo0To360Range(lambda0); //Step 14. Convert to equatorial coordinates beta = AASCoordinateTransformation.RadiansToDegrees(beta); AAS2DCoordinate GeocentricEclipticSaturn = AASCoordinateTransformation.Ecliptic2Equatorial(lambda, beta, Obliquity); double alpha = AASCoordinateTransformation.HoursToRadians(GeocentricEclipticSaturn.X); double delta = AASCoordinateTransformation.DegreesToRadians(GeocentricEclipticSaturn.Y); AAS2DCoordinate GeocentricEclipticNorthPole = AASCoordinateTransformation.Ecliptic2Equatorial(lambda0, beta0, Obliquity); double alpha0 = AASCoordinateTransformation.HoursToRadians(GeocentricEclipticNorthPole.X); double delta0 = AASCoordinateTransformation.DegreesToRadians(GeocentricEclipticNorthPole.Y); //Step 15. Calculate the Position angle details.P = AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(Math.Cos(delta0) * Math.Sin(alpha0 - alpha), Math.Sin(delta0) * Math.Cos(delta) - Math.Cos(delta0) * Math.Sin(delta) * Math.Cos(alpha0 - alpha))); return(details); }
public static AASRiseTransitSetDetails Calculate(double JD, double Alpha1, double Delta1, double Alpha2, double Delta2, double Alpha3, double Delta3, double Longitude, double Latitude, double h0) { //What will be the return value AASRiseTransitSetDetails details = new AASRiseTransitSetDetails(); details.bRiseValid = false; details.bSetValid = false; details.bTransitAboveHorizon = false; //Calculate the sidereal time double theta0 = AASSidereal.ApparentGreenwichSiderealTime(JD); theta0 *= 15; //Express it as degrees //Calculate deltat double deltaT = AASDynamicalTime.DeltaT(JD); //Convert values to radians double Delta2Rad = AASCoordinateTransformation.DegreesToRadians(Delta2); double LatitudeRad = AASCoordinateTransformation.DegreesToRadians(Latitude); //Convert the standard latitude to radians double h0Rad = AASCoordinateTransformation.DegreesToRadians(h0); double cosH0 = (Math.Sin(h0Rad) - Math.Sin(LatitudeRad) * Math.Sin(Delta2Rad)) / (Math.Cos(LatitudeRad) * Math.Cos(Delta2Rad)); //Calculate and ensure the M0 is in the range 0 to +1 double M0 = (Alpha2 * 15 + Longitude - theta0) / 360; while (M0 > 1) { M0 -= 1; } while (M0 < 0) { M0 += 1; } //Check that the object actually rises double M1 = 0; double M2 = 0; if ((cosH0 > -1) && (cosH0 < 1)) { details.bRiseValid = true; details.bSetValid = true; details.bTransitAboveHorizon = true; double H0 = Math.Acos(cosH0); H0 = AASCoordinateTransformation.RadiansToDegrees(H0); //Calculate and ensure the M1 and M2 is in the range 0 to +1 M1 = M0 - H0 / 360; M2 = M0 + H0 / 360; while (M1 > 1) { M1 -= 1; } while (M1 < 0) { M1 += 1; } while (M2 > 1) { M2 -= 1; } while (M2 < 0) { M2 += 1; } } else if (cosH0 < 1) { details.bTransitAboveHorizon = true; } //Ensure the RA values are corrected for interpolation. Due to important Remark 2 by Meeus on Interopolation of RA values if ((Alpha2 - Alpha1) > 12.0) { Alpha1 += 24; } else if ((Alpha2 - Alpha1) < -12.0) { Alpha2 += 24; } if ((Alpha3 - Alpha2) > 12.0) { Alpha2 += 24; } else if ((Alpha3 - Alpha2) < -12.0) { Alpha3 += 24; } for (int i = 0; i < 2; i++) { //Calculate the details of rising if (details.bRiseValid) { double theta1 = theta0 + 360.985647 * M1; theta1 = AASCoordinateTransformation.MapTo0To360Range(theta1); double n = M1 + deltaT / 86400; double Alpha = AASInterpolate.Interpolate(n, Alpha1, Alpha2, Alpha3); double Delta = AASInterpolate.Interpolate(n, Delta1, Delta2, Delta3); double H = theta1 - Longitude - Alpha * 15; AAS2DCoordinate Horizontal = AASCoordinateTransformation.Equatorial2Horizontal(H / 15, Delta, Latitude); double DeltaM = (Horizontal.Y - h0) / (360 * Math.Cos(AASCoordinateTransformation.DegreesToRadians(Delta)) * Math.Cos(LatitudeRad) * Math.Sin(AASCoordinateTransformation.DegreesToRadians(H))); M1 += DeltaM; } //Calculate the details of setting if (details.bSetValid) { double theta1 = theta0 + 360.985647 * M2; theta1 = AASCoordinateTransformation.MapTo0To360Range(theta1); double n = M2 + deltaT / 86400; double Alpha = AASInterpolate.Interpolate(n, Alpha1, Alpha2, Alpha3); double Delta = AASInterpolate.Interpolate(n, Delta1, Delta2, Delta3); double H = theta1 - Longitude - Alpha * 15; AAS2DCoordinate Horizontal = AASCoordinateTransformation.Equatorial2Horizontal(H / 15, Delta, Latitude); double DeltaM = (Horizontal.Y - h0) / (360 * Math.Cos(AASCoordinateTransformation.DegreesToRadians(Delta)) * Math.Cos(LatitudeRad) * Math.Sin(AASCoordinateTransformation.DegreesToRadians(H))); M2 += DeltaM; } { //Calculate the details of transit double theta1 = theta0 + 360.985647 * M0; theta1 = AASCoordinateTransformation.MapTo0To360Range(theta1); double n = M0 + deltaT / 86400; double Alpha = AASInterpolate.Interpolate(n, Alpha1, Alpha2, Alpha3); double H = theta1 - Longitude - Alpha * 15; H = AASCoordinateTransformation.MapTo0To360Range(H); if (H > 180) { H -= 360; } double DeltaM = -H / 360; M0 += DeltaM; } } details.Rise = details.bRiseValid ? (M1 * 24) : 0.0; details.Set = details.bSetValid ? (M2 * 24) : 0.0; details.Transit = M0 * 24; //We always return the transit time even if it occurs below the horizon return(details); }
public static CAAPhysicalMarsDetails Calculate(double JD, bool bHighPrecision) { //What will be the return value CAAPhysicalMarsDetails details = new CAAPhysicalMarsDetails(); //Step 1 double T = (JD - 2451545) / 36525; double Lambda0 = 352.9065 + 1.17330 * T; double Lambda0rad = AASCoordinateTransformation.DegreesToRadians(Lambda0); double Beta0 = 63.2818 - 0.00394 * T; double Beta0rad = AASCoordinateTransformation.DegreesToRadians(Beta0); //Step 2 double l0 = AASEarth.EclipticLongitude(JD, bHighPrecision); double l0rad = AASCoordinateTransformation.DegreesToRadians(l0); double b0 = AASEarth.EclipticLatitude(JD, bHighPrecision); double b0rad = AASCoordinateTransformation.DegreesToRadians(b0); double R = AASEarth.RadiusVector(JD, bHighPrecision); double PreviousLightTravelTime = 0; double LightTravelTime = 0; double x = 0; double y = 0; double z = 0; bool bIterate = true; double DELTA = 0; double l = 0; double lrad = 0; double b = 0; double r = 0; while (bIterate) { double JD2 = JD - LightTravelTime; //Step 3 l = AASMars.EclipticLongitude(JD2, bHighPrecision); lrad = AASCoordinateTransformation.DegreesToRadians(l); b = AASMars.EclipticLatitude(JD2, bHighPrecision); double brad = AASCoordinateTransformation.DegreesToRadians(b); r = AASMars.RadiusVector(JD2, bHighPrecision); //Step 4 x = r * Math.Cos(brad) * Math.Cos(lrad) - R * Math.Cos(l0rad); y = r * Math.Cos(brad) * Math.Sin(lrad) - R * Math.Sin(l0rad); z = r * Math.Sin(brad) - R * Math.Sin(b0rad); DELTA = Math.Sqrt(x * x + y * y + z * z); LightTravelTime = AASElliptical.DistanceToLightTime(DELTA); //Prepare for the next loop around bIterate = (Math.Abs(LightTravelTime - PreviousLightTravelTime) > 2E-6); //2E-6 correponds to 0.17 of a second if (bIterate) { PreviousLightTravelTime = LightTravelTime; } } //Step 5 double lambdarad = Math.Atan2(y, x); double lambda = AASCoordinateTransformation.RadiansToDegrees(lambdarad); double betarad = Math.Atan2(z, Math.Sqrt(x * x + y * y)); double beta = AASCoordinateTransformation.RadiansToDegrees(betarad); //Step 6 details.DE = AASCoordinateTransformation.RadiansToDegrees(Math.Asin(-Math.Sin(Beta0rad) * Math.Sin(betarad) - Math.Cos(Beta0rad) * Math.Cos(betarad) * Math.Cos(Lambda0rad - lambdarad))); //Step 7 double N = 49.5581 + 0.7721 * T; double Nrad = AASCoordinateTransformation.DegreesToRadians(N); double ldash = l - 0.00697 / r; double ldashrad = AASCoordinateTransformation.DegreesToRadians(ldash); double bdash = b - 0.000225 * (Math.Cos(lrad - Nrad) / r); double bdashrad = AASCoordinateTransformation.DegreesToRadians(bdash); //Step 8 details.DS = AASCoordinateTransformation.RadiansToDegrees(Math.Asin(-Math.Sin(Beta0rad) * Math.Sin(bdashrad) - Math.Cos(Beta0rad) * Math.Cos(bdashrad) * Math.Cos(Lambda0rad - ldashrad))); //Step 9 double W = AASCoordinateTransformation.MapTo0To360Range(11.504 + 350.89200025 * (JD - LightTravelTime - 2433282.5)); //Step 10 double e0 = AASNutation.MeanObliquityOfEcliptic(JD); double e0rad = AASCoordinateTransformation.DegreesToRadians(e0); AAS2DCoordinate PoleEquatorial = AASCoordinateTransformation.Ecliptic2Equatorial(Lambda0, Beta0, e0); double alpha0rad = AASCoordinateTransformation.HoursToRadians(PoleEquatorial.X); double delta0rad = AASCoordinateTransformation.DegreesToRadians(PoleEquatorial.Y); //Step 11 double u = y * Math.Cos(e0rad) - z * Math.Sin(e0rad); double v = y * Math.Sin(e0rad) + z * Math.Cos(e0rad); double alpharad = Math.Atan2(u, x); double alpha = AASCoordinateTransformation.RadiansToHours(alpharad); double deltarad = Math.Atan2(v, Math.Sqrt(x * x + u * u)); double delta = AASCoordinateTransformation.RadiansToDegrees(deltarad); double xi = Math.Atan2(Math.Sin(delta0rad) * Math.Cos(deltarad) * Math.Cos(alpha0rad - alpharad) - Math.Sin(deltarad) * Math.Cos(delta0rad), Math.Cos(deltarad) * Math.Sin(alpha0rad - alpharad)); //Step 12 details.w = AASCoordinateTransformation.MapTo0To360Range(W - AASCoordinateTransformation.RadiansToDegrees(xi)); //Step 13 double NutationInLongitude = AASNutation.NutationInLongitude(JD); double NutationInObliquity = AASNutation.NutationInObliquity(JD); //Step 14 lambda += 0.005693 * Math.Cos(l0rad - lambdarad) / Math.Cos(betarad); beta += 0.005693 * Math.Sin(l0rad - lambdarad) * Math.Sin(betarad); //Step 15 Lambda0 += NutationInLongitude / 3600; lambda += NutationInLongitude / 3600; e0 += NutationInObliquity / 3600; //Step 16 AAS2DCoordinate ApparentPoleEquatorial = AASCoordinateTransformation.Ecliptic2Equatorial(Lambda0, Beta0, e0); double alpha0dash = AASCoordinateTransformation.HoursToRadians(ApparentPoleEquatorial.X); double delta0dash = AASCoordinateTransformation.DegreesToRadians(ApparentPoleEquatorial.Y); AAS2DCoordinate ApparentMars = AASCoordinateTransformation.Ecliptic2Equatorial(lambda, beta, e0); double alphadash = AASCoordinateTransformation.HoursToRadians(ApparentMars.X); double deltadash = AASCoordinateTransformation.DegreesToRadians(ApparentMars.Y); //Step 17 details.P = AASCoordinateTransformation.MapTo0To360Range(AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(Math.Cos(delta0dash) * Math.Sin(alpha0dash - alphadash), Math.Sin(delta0dash) * Math.Cos(deltadash) - Math.Cos(delta0dash) * Math.Sin(deltadash) * Math.Cos(alpha0dash - alphadash)))); //Step 18 double SunLambda = AASSun.GeometricEclipticLongitude(JD, bHighPrecision); double SunBeta = AASSun.GeometricEclipticLatitude(JD, bHighPrecision); AAS2DCoordinate SunEquatorial = AASCoordinateTransformation.Ecliptic2Equatorial(SunLambda, SunBeta, e0); details.X = AASMoonIlluminatedFraction.PositionAngle(SunEquatorial.X, SunEquatorial.Y, alpha, delta); //Step 19 details.d = 9.36 / DELTA; details.k = AASIlluminatedFraction.IlluminatedFraction(r, R, DELTA); details.q = (1 - details.k) * details.d; return(details); }