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); }
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 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 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); }