public static CAA2DCoordinate Equatorial2Topocentric(double Alpha, double Delta, double Distance, double Longitude, double Latitude, double Height, double JD) { double RhoSinThetaPrime = CAAGlobe.RhoSinThetaPrime(Latitude, Height); double RhoCosThetaPrime = CAAGlobe.RhoCosThetaPrime(Latitude, Height); //Calculate the Sidereal time double theta = CAASidereal.ApparentGreenwichSiderealTime(JD); //Convert to radians Delta = CAACoordinateTransformation.DegreesToRadians(Delta); double cosDelta = Math.Cos(Delta); //Calculate the Parallax double pi = Math.Asin(GlobalMembersStdafx.g_AAParallax_C1 / Distance); double sinpi = Math.Sin(pi); //Calculate the hour angle double H = CAACoordinateTransformation.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); CAA2DCoordinate Topocentric = new CAA2DCoordinate(); Topocentric.X = CAACoordinateTransformation.MapTo0To24Range(Alpha + CAACoordinateTransformation.RadiansToHours(DeltaAlpha)); Topocentric.Y = CAACoordinateTransformation.RadiansToDegrees(Math.Atan2((Math.Sin(Delta) - RhoSinThetaPrime * sinpi) * Math.Cos(DeltaAlpha), cosDelta - RhoCosThetaPrime * sinpi * cosH)); return(Topocentric); }
//Conversion functions public static CAA2DCoordinate Equatorial2TopocentricDelta(double Alpha, double Delta, double Distance, double Longitude, double Latitude, double Height, double JD) { double RhoSinThetaPrime = CAAGlobe.RhoSinThetaPrime(Latitude, Height); double RhoCosThetaPrime = CAAGlobe.RhoCosThetaPrime(Latitude, Height); //Calculate the Sidereal time double theta = CAASidereal.ApparentGreenwichSiderealTime(JD); //Convert to radians Delta = CAACoordinateTransformation.DegreesToRadians(Delta); double cosDelta = Math.Cos(Delta); //Calculate the Parallax double pi = Math.Asin(GlobalMembersStdafx.g_AAParallax_C1 / Distance); //Calculate the hour angle double H = CAACoordinateTransformation.HoursToRadians(theta - Longitude / 15 - Alpha); double cosH = Math.Cos(H); double sinH = Math.Sin(H); CAA2DCoordinate DeltaTopocentric = new CAA2DCoordinate(); DeltaTopocentric.X = CAACoordinateTransformation.RadiansToHours(-pi * RhoCosThetaPrime * sinH / cosDelta); DeltaTopocentric.Y = CAACoordinateTransformation.RadiansToDegrees(-pi * (RhoSinThetaPrime * cosDelta - RhoCosThetaPrime * cosH * Math.Sin(Delta))); return(DeltaTopocentric); }
public static COR Equatorial2Topocentric(double Alpha, double Delta, double Distance, double Longitude, double Latitude, double Height, double JD) { double RhoSinThetaPrime = CAAGlobe.RhoSinThetaPrime(Latitude, Height); double RhoCosThetaPrime = CAAGlobe.RhoCosThetaPrime(Latitude, Height); //Calculate the Sidereal time double theta = CAASidereal.ApparentGreenwichSiderealTime(JD); //Convert to radians Delta = CT.D2R(Delta); double cosDelta = Math.Cos(Delta); //Calculate the Parallax double pi = Math.Asin(GFX.g_AAParallax_C1 / Distance); double sinpi = Math.Sin(pi); //Calculate the hour angle double H = CT.H2R(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); COR Topocentric = new COR(); Topocentric.X = CT.M24(Alpha + CT.R2H(DeltaAlpha)); Topocentric.Y = CT.R2D(Math.Atan2((Math.Sin(Delta) - RhoSinThetaPrime * sinpi) * Math.Cos(DeltaAlpha), cosDelta - RhoCosThetaPrime * sinpi * cosH)); return(Topocentric); }
//Conversion functions public static COR Equatorial2TopocentricDelta(double Alpha, double Delta, double Distance, double Longitude, double Latitude, double Height, double JD) { double RhoSinThetaPrime = CAAGlobe.RhoSinThetaPrime(Latitude, Height); double RhoCosThetaPrime = CAAGlobe.RhoCosThetaPrime(Latitude, Height); //Calculate the Sidereal time double theta = CAASidereal.ApparentGreenwichSiderealTime(JD); //Convert to radians Delta = CT.D2R(Delta); double cosDelta = Math.Cos(Delta); //Calculate the Parallax double pi = Math.Asin(GFX.g_AAParallax_C1 / Distance); //Calculate the hour angle double H = CT.H2R(theta - Longitude / 15 - Alpha); double cosH = Math.Cos(H); double sinH = Math.Sin(H); COR DeltaTopocentric = new COR(); DeltaTopocentric.X = CT.R2H(-pi * RhoCosThetaPrime * sinH / cosDelta); DeltaTopocentric.Y = CT.R2D(-pi * (RhoSinThetaPrime * cosDelta - RhoCosThetaPrime * cosH * Math.Sin(Delta))); return(DeltaTopocentric); }
public static CAATopocentricEclipticDetails Ecliptic2Topocentric(double Lambda, double Beta, double Semidiameter, double Distance, double Epsilon, double Longitude, double Latitude, double Height, double JD) { double S = CAAGlobe.RhoSinThetaPrime(Latitude, Height); double C = CAAGlobe.RhoCosThetaPrime(Latitude, Height); //Convert to radians Lambda = CAACoordinateTransformation.DegreesToRadians(Lambda); Beta = CAACoordinateTransformation.DegreesToRadians(Beta); Epsilon = CAACoordinateTransformation.DegreesToRadians(Epsilon); Longitude = CAACoordinateTransformation.DegreesToRadians(Longitude); Latitude = CAACoordinateTransformation.DegreesToRadians(Latitude); Semidiameter = CAACoordinateTransformation.DegreesToRadians(Semidiameter); double sine = Math.Sin(Epsilon); double cose = Math.Cos(Epsilon); double cosBeta = Math.Cos(Beta); double sinBeta = Math.Sin(Beta); //Calculate the Sidereal time double theta = CAASidereal.ApparentGreenwichSiderealTime(JD); theta = CAACoordinateTransformation.HoursToRadians(theta); double sintheta = Math.Sin(theta); //Calculate the Parallax double pi = Math.Asin(GlobalMembersStdafx.g_AAParallax_C1 / Distance); double sinpi = Math.Sin(pi); double N = Math.Cos(Lambda) * cosBeta - C * sinpi * Math.Cos(theta); CAATopocentricEclipticDetails Topocentric = new CAATopocentricEclipticDetails(); Topocentric.Lambda = Math.Atan2(Math.Sin(Lambda) * cosBeta - sinpi * (S * sine + C * cose * sintheta), N); double cosTopocentricLambda = Math.Cos(Topocentric.Lambda); Topocentric.Beta = Math.Atan(cosTopocentricLambda * (sinBeta - sinpi * (S * cose - C * sine * sintheta)) / N); Topocentric.Semidiameter = Math.Asin(cosTopocentricLambda * Math.Cos(Topocentric.Beta) * Math.Sin(Semidiameter) / N); //Convert back to degrees Topocentric.Semidiameter = CAACoordinateTransformation.RadiansToDegrees(Topocentric.Semidiameter); Topocentric.Lambda = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Topocentric.Lambda)); Topocentric.Beta = CAACoordinateTransformation.RadiansToDegrees(Topocentric.Beta); return(Topocentric); }
public static CAAPhysicalMoonDetails CalculateTopocentric(double JD, double Longitude, double Latitude) { //First convert to radians Longitude = CAACoordinateTransformation.DegreesToRadians(Longitude); Latitude = CAACoordinateTransformation.DegreesToRadians(Latitude); double Lambda = 0; double Beta = 0; double epsilon = 0; CAA2DCoordinate Equatorial = new CAA2DCoordinate(); CAAPhysicalMoonDetails details = CalculateHelper(JD, ref Lambda, ref Beta, ref epsilon, ref Equatorial); double R = CAAMoon.RadiusVector(JD); double pi = CAAMoon.RadiusVectorToHorizontalParallax(R); double Alpha = CAACoordinateTransformation.HoursToRadians(Equatorial.X); double Delta = CAACoordinateTransformation.DegreesToRadians(Equatorial.Y); double AST = CAASidereal.ApparentGreenwichSiderealTime(JD); double H = CAACoordinateTransformation.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 = CAACoordinateTransformation.DegreesToRadians(details.P); double DeltaL = -pidash *Math.Sin(Q - Prad) / Math.Cos(CAACoordinateTransformation.DegreesToRadians(details.b)); details.l += DeltaL; double DeltaB = pidash * Math.Cos(Q - Prad); details.b += DeltaB; details.P += DeltaL * Math.Sin(CAACoordinateTransformation.DegreesToRadians(details.b)) - pidash * Math.Sin(Q) * Math.Tan(Delta); return(details); }
//Static methods ///////////////////////////// Implementation ////////////////////////////////// public static CAARiseTransitSetDetails Rise(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 CAARiseTransitSetDetails details = new CAARiseTransitSetDetails(); details.bValid = false; //Calculate the sidereal time double theta0 = CAASidereal.ApparentGreenwichSiderealTime(JD); theta0 *= 15; //Express it as degrees //Calculate deltat double deltaT = DYT.DeltaT(JD); //Convert values to radians double Delta2Rad = CT.D2R(Delta2); double LatitudeRad = CT.D2R(Latitude); //Convert the standard latitude to radians double h0Rad = CT.D2R(h0); double cosH0 = (Math.Sin(h0Rad) - Math.Sin(LatitudeRad) * Math.Sin(Delta2Rad)) / (Math.Cos(LatitudeRad) * Math.Cos(Delta2Rad)); //Check that the object actually rises if ((cosH0 > 1) || (cosH0 < -1)) { return(details); } double H0 = Math.Acos(cosH0); H0 = CT.R2D(H0); double M0 = (Alpha2 * 15 + Longitude - theta0) / 360; double M1 = M0 - H0 / 360; double M2 = M0 + H0 / 360; if (M0 > 1) { M0 -= 1; } else if (M0 < 0) { M0 += 1; } if (M1 > 1) { M1 -= 1; } else if (M1 < 0) { M1 += 1; } if (M2 > 1) { M2 -= 1; } else if (M2 < 0) { M2 += 1; } for (int i = 0; i < 2; i++) { //Calculate the details of rising double theta1 = theta0 + 360.985647 * M1; theta1 = CT.M360(theta1); double n = M1 + deltaT / 86400; double Alpha = INTP.Interpolate(n, Alpha1, Alpha2, Alpha3); double Delta = INTP.Interpolate(n, Delta1, Delta2, Delta3); double H = theta1 - Longitude - Alpha * 15; COR Horizontal = CT.Eq2H(H / 15, Delta, Latitude); double DeltaM = (Horizontal.Y - h0) / (360 * Math.Cos(CT.D2R(Delta)) * Math.Cos(LatitudeRad) * Math.Sin(CT.D2R(H))); M1 += DeltaM; //Calculate the details of transit theta1 = theta0 + 360.985647 * M0; theta1 = CT.M360(theta1); n = M0 + deltaT / 86400; Alpha = INTP.Interpolate(n, Alpha1, Alpha2, Alpha3); H = theta1 - Longitude - Alpha * 15; if (H < -180) { H += 360; } DeltaM = -H / 360; M0 += DeltaM; //Calculate the details of setting theta1 = theta0 + 360.985647 * M2; theta1 = CT.M360(theta1); n = M2 + deltaT / 86400; Alpha = INTP.Interpolate(n, Alpha1, Alpha2, Alpha3); Delta = INTP.Interpolate(n, Delta1, Delta2, Delta3); H = theta1 - Longitude - Alpha * 15; Horizontal = CT.Eq2H(H / 15, Delta, Latitude); DeltaM = (Horizontal.Y - h0) / (360 * Math.Cos(CT.D2R(Delta)) * Math.Cos(LatitudeRad) * Math.Sin(CT.D2R(H))); M2 += DeltaM; } //Finally before we exit, convert to hours details.bValid = true; details.Rise = M1 * 24; details.Set = M2 * 24; details.Transit = M0 * 24; return(details); }