//Static methods ///////////////////////// Implementation ////////////////////////////////////// public static double Calculate(double JD) { double rho = (JD - 2451545) / 365250; double rhosquared = rho * rho; double rhocubed = rhosquared * rho; double rho4 = rhocubed * rho; double rho5 = rho4 * rho; //Calculate the Suns mean longitude double L0 = CAACoordinateTransformation.MapTo0To360Range(280.4664567 + 360007.6982779 * rho + 0.03032028 * rhosquared + rhocubed / 49931 - rho4 / 15300 - rho5 / 2000000); //Calculate the Suns apparent right ascension double SunLong = CAASun.ApparentEclipticLongitude(JD); double SunLat = CAASun.ApparentEclipticLatitude(JD); double epsilon = CAANutation.TrueObliquityOfEcliptic(JD); CAA2DCoordinate Equatorial = CAACoordinateTransformation.Ecliptic2Equatorial(SunLong, SunLat, epsilon); epsilon = CAACoordinateTransformation.DegreesToRadians(epsilon); double E = L0 - 0.0057183 - Equatorial.X * 15 + CAACoordinateTransformation.DMSToDegrees(0, 0, CAANutation.NutationInLongitude(JD)) * Math.Cos(epsilon); if (E > 180) { E = -(360 - E); } E *= 4; //Convert to minutes of time return(E); }
protected static CAAPhysicalMoonDetails CalculateHelper(double JD, ref double Lambda, ref double Beta, ref double epsilon, ref CAA2DCoordinate Equatorial) { //What will be the return value CAAPhysicalMoonDetails details = new CAAPhysicalMoonDetails(); //Calculate the initial quantities Lambda = CAAMoon.EclipticLongitude(JD); Beta = CAAMoon.EclipticLatitude(JD); //Calculate the optical libration double omega = 0; double DeltaU = 0; double sigma = 0; double I = 0; double rho = 0; CalculateOpticalLibration(JD, Lambda, Beta, ref details.ldash, ref details.bdash, ref details.ldash2, ref details.bdash2, ref epsilon, ref omega, ref DeltaU, ref sigma, ref I, ref rho); double epsilonrad = CAACoordinateTransformation.DegreesToRadians(epsilon); //Calculate the total libration details.l = details.ldash + details.ldash2; details.b = details.bdash + details.bdash2; double b = CAACoordinateTransformation.DegreesToRadians(details.b); //Calculate the position angle double V = omega + DeltaU + CAACoordinateTransformation.DegreesToRadians(sigma) / Math.Sin(I); double I_rho = I + CAACoordinateTransformation.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 = CAACoordinateTransformation.Ecliptic2Equatorial(Lambda, Beta, epsilon); double Alpha = CAACoordinateTransformation.HoursToRadians(Equatorial.X); details.P = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sqrt(X * X + Y * Y) * Math.Cos(Alpha - w) / (Math.Cos(b)))); return(details); }
//Static methods //////////////////////////////// Implementation /////////////////////////////// public static CAASaturnRingDetails Calculate(double JD) { //What will be the return value CAASaturnRingDetails details = new CAASaturnRingDetails(); 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 = CAACoordinateTransformation.DegreesToRadians(i); double omega = 169.508470 + 1.394681 * T + 0.000412 * T2; double omegarad = CAACoordinateTransformation.DegreesToRadians(omega); //Step 2. Calculate the heliocentric longitude, latitude and radius vector of the Earth in the FK5 system double l0 = CAAEarth.EclipticLongitude(JD); double b0 = CAAEarth.EclipticLatitude(JD); l0 += CAAFK5.CorrectionInLongitude(l0, b0, JD); double l0rad = CAACoordinateTransformation.DegreesToRadians(l0); b0 += CAAFK5.CorrectionInLatitude(l0, JD); double b0rad = CAACoordinateTransformation.DegreesToRadians(b0); double R = CAAEarth.RadiusVector(JD); //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 = CAAElliptical.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 = CAASaturn.EclipticLongitude(JD1); b = CAASaturn.EclipticLatitude(JD1); l += CAAFK5.CorrectionInLongitude(l, b, JD1); b += CAAFK5.CorrectionInLatitude(l, JD1); double lrad = CAACoordinateTransformation.DegreesToRadians(l); double brad = CAACoordinateTransformation.DegreesToRadians(b); r = CAASaturn.RadiusVector(JD1); //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 = CAAElliptical.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 = CAACoordinateTransformation.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 = CAACoordinateTransformation.DegreesToRadians(N); double ldash = l - 0.01759 / r; double ldashrad = CAACoordinateTransformation.DegreesToRadians(ldash); double bdash = b - 0.000764 * Math.Cos(ldashrad - Nrad) / r; double bdashrad = CAACoordinateTransformation.DegreesToRadians(bdash); //Step 8. Calculate Bdash details.Bdash = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sin(irad) * Math.Cos(bdashrad) * Math.Sin(ldashrad - omegarad) - Math.Cos(irad) * Math.Sin(bdashrad))); //Step 9. Calculate DeltaU double U1 = 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)); double U2 = 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 = CAACoordinateTransformation.RadiansToDegrees(Math.Abs(U1 - U2)); //Step 10. Calculate the Nutations double Obliquity = CAANutation.TrueObliquityOfEcliptic(JD); double NutationInLongitude = CAANutation.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 += CAACoordinateTransformation.DegreesToRadians(0.005693 * Math.Cos(l0rad - lambda) / Math.Cos(beta)); beta += CAACoordinateTransformation.DegreesToRadians(0.005693 * Math.Sin(l0rad - lambda) * Math.Sin(beta)); //Step 13. Add nutation in longitude to lambda0 and lambda //double NLrad = CAACoordinateTransformation::DegreesToRadians(NutationInLongitude/3600); lambda = CAACoordinateTransformation.RadiansToDegrees(lambda); lambda += NutationInLongitude / 3600; lambda = CAACoordinateTransformation.MapTo0To360Range(lambda); lambda0 += NutationInLongitude / 3600; lambda0 = CAACoordinateTransformation.MapTo0To360Range(lambda0); //Step 14. Convert to equatorial coordinates beta = CAACoordinateTransformation.RadiansToDegrees(beta); CAA2DCoordinate GeocentricEclipticSaturn = CAACoordinateTransformation.Ecliptic2Equatorial(lambda, beta, Obliquity); double alpha = CAACoordinateTransformation.HoursToRadians(GeocentricEclipticSaturn.X); double delta = CAACoordinateTransformation.DegreesToRadians(GeocentricEclipticSaturn.Y); CAA2DCoordinate GeocentricEclipticNorthPole = CAACoordinateTransformation.Ecliptic2Equatorial(lambda0, beta0, Obliquity); double alpha0 = CAACoordinateTransformation.HoursToRadians(GeocentricEclipticNorthPole.X); double delta0 = CAACoordinateTransformation.DegreesToRadians(GeocentricEclipticNorthPole.Y); //Step 15. Calculate the Position angle details.P = CAACoordinateTransformation.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 CAAEllipticalPlanetaryDetails Calculate(double JD, EllipticalObject @object) { //What will the the return value CAAEllipticalPlanetaryDetails details = new CAAEllipticalPlanetaryDetails(); double JD0 = JD; double L0 = 0; double B0 = 0; double R0 = 0; double cosB0 = 0; if (@object != EllipticalObject.SUN) { L0 = CAAEarth.EclipticLongitude(JD0); B0 = CAAEarth.EclipticLatitude(JD0); R0 = CAAEarth.RadiusVector(JD0); L0 = CAACoordinateTransformation.DegreesToRadians(L0); B0 = CAACoordinateTransformation.DegreesToRadians(B0); cosB0 = Math.Cos(B0); } //Calculate the initial values double L = 0; double B = 0; double R = 0; double Lrad; double Brad; double cosB; double cosL; double x; double y; double z; bool bRecalc = true; bool bFirstRecalc = true; double LPrevious = 0; double BPrevious = 0; double RPrevious = 0; while (bRecalc) { switch (@object) { case EllipticalObject.SUN: { L = CAASun.GeometricEclipticLongitude(JD0); B = CAASun.GeometricEclipticLatitude(JD0); R = CAAEarth.RadiusVector(JD0); break; } case EllipticalObject.MERCURY: { L = CAAMercury.EclipticLongitude(JD0); B = CAAMercury.EclipticLatitude(JD0); R = CAAMercury.RadiusVector(JD0); break; } case EllipticalObject.VENUS: { L = CAAVenus.EclipticLongitude(JD0); B = CAAVenus.EclipticLatitude(JD0); R = CAAVenus.RadiusVector(JD0); break; } case EllipticalObject.MARS: { L = CAAMars.EclipticLongitude(JD0); B = CAAMars.EclipticLatitude(JD0); R = CAAMars.RadiusVector(JD0); break; } case EllipticalObject.JUPITER: { L = CAAJupiter.EclipticLongitude(JD0); B = CAAJupiter.EclipticLatitude(JD0); R = CAAJupiter.RadiusVector(JD0); break; } case EllipticalObject.SATURN: { L = CAASaturn.EclipticLongitude(JD0); B = CAASaturn.EclipticLatitude(JD0); R = CAASaturn.RadiusVector(JD0); break; } case EllipticalObject.URANUS: { L = CAAUranus.EclipticLongitude(JD0); B = CAAUranus.EclipticLatitude(JD0); R = CAAUranus.RadiusVector(JD0); break; } case EllipticalObject.NEPTUNE: { L = CAANeptune.EclipticLongitude(JD0); B = CAANeptune.EclipticLatitude(JD0); R = CAANeptune.RadiusVector(JD0); break; } case EllipticalObject.PLUTO: { L = CAAPluto.EclipticLongitude(JD0); B = CAAPluto.EclipticLatitude(JD0); R = CAAPluto.RadiusVector(JD0); break; } default: { Debug.Assert(false); break; } } if (!bFirstRecalc) { bRecalc = ((Math.Abs(L - LPrevious) > 0.00001) || (Math.Abs(B - BPrevious) > 0.00001) || (Math.Abs(R - RPrevious) > 0.000001)); LPrevious = L; BPrevious = B; RPrevious = R; } else { bFirstRecalc = false; } //Calculate the new value if (bRecalc) { double distance = 0; if (@object != EllipticalObject.SUN) { Lrad = CAACoordinateTransformation.DegreesToRadians(L); Brad = CAACoordinateTransformation.DegreesToRadians(B); cosB = Math.Cos(Brad); cosL = Math.Cos(Lrad); x = R * cosB * cosL - R0 * cosB0 * Math.Cos(L0); y = R * cosB * Math.Sin(Lrad) - R0 * cosB0 * Math.Sin(L0); z = R * Math.Sin(Brad) - R0 * Math.Sin(B0); distance = Math.Sqrt(x * x + y * y + z * z); } else { distance = R; //Distance to the sun from the earth is in fact the radius vector } //Prepare for the next loop around JD0 = JD - CAAElliptical.DistanceToLightTime(distance); } } Lrad = CAACoordinateTransformation.DegreesToRadians(L); Brad = CAACoordinateTransformation.DegreesToRadians(B); cosB = Math.Cos(Brad); cosL = Math.Cos(Lrad); x = R * cosB * cosL - R0 * cosB0 * Math.Cos(L0); y = R * cosB * Math.Sin(Lrad) - R0 * cosB0 * Math.Sin(L0); z = R * Math.Sin(Brad) - R0 * Math.Sin(B0); double x2 = x * x; double y2 = y * y; details.ApparentGeocentricLatitude = CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(z, Math.Sqrt(x2 + y2))); details.ApparentGeocentricDistance = Math.Sqrt(x2 + y2 + z * z); details.ApparentGeocentricLongitude = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(y, x))); details.ApparentLightTime = CAAElliptical.DistanceToLightTime(details.ApparentGeocentricDistance); //Adjust for Aberration CAA2DCoordinate Aberration = CAAAberration.EclipticAberration(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, JD); details.ApparentGeocentricLongitude += Aberration.X; details.ApparentGeocentricLatitude += Aberration.Y; //convert to the FK5 system double DeltaLong = CAAFK5.CorrectionInLongitude(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, JD); details.ApparentGeocentricLatitude += CAAFK5.CorrectionInLatitude(details.ApparentGeocentricLongitude, JD); details.ApparentGeocentricLongitude += DeltaLong; //Correct for nutation double NutationInLongitude = CAANutation.NutationInLongitude(JD); double Epsilon = CAANutation.TrueObliquityOfEcliptic(JD); details.ApparentGeocentricLongitude += CAACoordinateTransformation.DMSToDegrees(0, 0, NutationInLongitude); //Convert to RA and Dec CAA2DCoordinate ApparentEqu = CAACoordinateTransformation.Ecliptic2Equatorial(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, Epsilon); details.ApparentGeocentricRA = ApparentEqu.X; details.ApparentGeocentricDeclination = ApparentEqu.Y; return(details); }
public static AstroRaDec GetPlanet(double jDate, int planet, double locLat, double locLong, double locHeight) { locLong = -locLong; if (planet < 9) { CAAEllipticalPlanetaryDetails Details = CAAElliptical.Calculate(jDate, (EllipticalObject)planet); CAA2DCoordinate corrected = CAAParallax.Equatorial2Topocentric(Details.ApparentGeocentricRA, Details.ApparentGeocentricDeclination, Details.ApparentGeocentricDistance, locLong, locLat, locHeight, jDate); return(new AstroRaDec(corrected.X, corrected.Y, Details.ApparentGeocentricDistance, false, false)); } else if (planet == 9) { double lat = CAAMoon.EclipticLatitude(jDate); double lng = CAAMoon.EclipticLongitude(jDate); double dis = CAAMoon.RadiusVector(jDate) / 149598000; double epsilon = CAANutation.TrueObliquityOfEcliptic(jDate); CAA2DCoordinate d = CAACoordinateTransformation.Ecliptic2Equatorial(lng, lat, epsilon); CAA2DCoordinate corrected = CAAParallax.Equatorial2Topocentric(d.X, d.Y, dis, locLong, locLat, locHeight, jDate); return(new AstroRaDec(corrected.X, corrected.Y, dis, false, false)); } else { if (jDate != jDateLast) { jupDetails = CAAElliptical.Calculate(jDate, (EllipticalObject)4); jupPhisical = CAAPhysicalJupiter.Calculate(jDate); CAA2DCoordinate corrected = CAAParallax.Equatorial2Topocentric(jupDetails.ApparentGeocentricRA, jupDetails.ApparentGeocentricDeclination, jupDetails.ApparentGeocentricDistance, locLong, locLat, locHeight, jDate); jupDetails.ApparentGeocentricRA = corrected.X; jupDetails.ApparentGeocentricDeclination = corrected.Y; galDetails = CAAGalileanMoons.Calculate(jDate); jDateLast = jDate; } double jupiterDiameter = 0.000954501; double scale = (Math.Atan(.5 * (jupiterDiameter / jupDetails.ApparentGeocentricDistance))) / 3.1415927 * 180; double raScale = (scale / Math.Cos(jupDetails.ApparentGeocentricDeclination / 180.0 * 3.1415927)) / 15; double xMoon = 0; double yMoon = 0; double zMoon = 0; bool shadow = false; bool eclipsed = false; switch (planet) { case 10: // IO xMoon = galDetails.Satellite1.ApparentRectangularCoordinates.X; yMoon = galDetails.Satellite1.ApparentRectangularCoordinates.Y; zMoon = galDetails.Satellite1.ApparentRectangularCoordinates.Z; eclipsed = galDetails.Satellite1.bInEclipse; shadow = galDetails.Satellite1.bInShadowTransit; break; case 11: //Europa xMoon = galDetails.Satellite2.ApparentRectangularCoordinates.X; yMoon = galDetails.Satellite2.ApparentRectangularCoordinates.Y; zMoon = galDetails.Satellite2.ApparentRectangularCoordinates.Z; eclipsed = galDetails.Satellite2.bInEclipse; shadow = galDetails.Satellite2.bInShadowTransit; break; case 12: //Ganymede xMoon = galDetails.Satellite3.ApparentRectangularCoordinates.X; yMoon = galDetails.Satellite3.ApparentRectangularCoordinates.Y; zMoon = galDetails.Satellite3.ApparentRectangularCoordinates.Z; eclipsed = galDetails.Satellite3.bInEclipse; shadow = galDetails.Satellite3.bInShadowTransit; break; case 13: //Callisto xMoon = galDetails.Satellite4.ApparentRectangularCoordinates.X; yMoon = galDetails.Satellite4.ApparentRectangularCoordinates.Y; zMoon = galDetails.Satellite4.ApparentRectangularCoordinates.Z; eclipsed = galDetails.Satellite4.bInEclipse; shadow = galDetails.Satellite4.bInShadowTransit; break; case 14: // IO Shadow xMoon = galDetails.Satellite1.ApparentShadowRectangularCoordinates.X; yMoon = galDetails.Satellite1.ApparentShadowRectangularCoordinates.Y; zMoon = galDetails.Satellite1.ApparentShadowRectangularCoordinates.Z * .9; shadow = galDetails.Satellite1.bInShadowTransit; break; case 15: //Europa Shadow xMoon = galDetails.Satellite2.ApparentShadowRectangularCoordinates.X; yMoon = galDetails.Satellite2.ApparentShadowRectangularCoordinates.Y; zMoon = galDetails.Satellite2.ApparentShadowRectangularCoordinates.Z * .9; shadow = galDetails.Satellite2.bInShadowTransit; break; case 16: //Ganymede Shadow xMoon = galDetails.Satellite3.ApparentShadowRectangularCoordinates.X; yMoon = galDetails.Satellite3.ApparentShadowRectangularCoordinates.Y; zMoon = galDetails.Satellite3.ApparentShadowRectangularCoordinates.Z * .9; shadow = galDetails.Satellite3.bInShadowTransit; break; case 17: //Callisto Shadow xMoon = galDetails.Satellite4.ApparentShadowRectangularCoordinates.X; yMoon = galDetails.Satellite4.ApparentShadowRectangularCoordinates.Y; zMoon = galDetails.Satellite4.ApparentShadowRectangularCoordinates.Z * .9; shadow = galDetails.Satellite4.bInShadowTransit; break; } double xTemp; double yTemp; double radians = jupPhisical.P / 180.0 * 3.1415927; xTemp = xMoon * Math.Cos(radians) - yMoon * Math.Sin(radians); yTemp = xMoon * Math.Sin(radians) + yMoon * Math.Cos(radians); xMoon = xTemp; yMoon = yTemp; return(new AstroRaDec(jupDetails.ApparentGeocentricRA - (xMoon * raScale), jupDetails.ApparentGeocentricDeclination + yMoon * scale, jupDetails.ApparentGeocentricDistance + (zMoon * jupiterDiameter / 2), shadow, eclipsed)); } }
public static AstroRaDec EclipticToJ2000(double l, double b, double jNow) { CAA2DCoordinate radec = CAACoordinateTransformation.Ecliptic2Equatorial(l, b, CAANutation.TrueObliquityOfEcliptic(jNow)); return(new AstroRaDec(radec.X, radec.Y, 0, false, false)); }
//Static methods //////////////////////////////// Implementation /////////////////////////////// public static CAAPhysicalMarsDetails Calculate(double JD) { //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 = CAACoordinateTransformation.DegreesToRadians(Lambda0); double Beta0 = 63.2818 - 0.00394 * T; double Beta0rad = CAACoordinateTransformation.DegreesToRadians(Beta0); //Step 2 double l0 = CAAEarth.EclipticLongitude(JD); double l0rad = CAACoordinateTransformation.DegreesToRadians(l0); double b0 = CAAEarth.EclipticLatitude(JD); double b0rad = CAACoordinateTransformation.DegreesToRadians(b0); double R = CAAEarth.RadiusVector(JD); 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 brad = 0; double r = 0; while (bIterate) { double JD2 = JD - LightTravelTime; //Step 3 l = CAAMars.EclipticLongitude(JD2); lrad = CAACoordinateTransformation.DegreesToRadians(l); b = CAAMars.EclipticLatitude(JD2); brad = CAACoordinateTransformation.DegreesToRadians(b); r = CAAMars.RadiusVector(JD2); //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 = CAAElliptical.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 = CAACoordinateTransformation.RadiansToDegrees(lambdarad); double betarad = Math.Atan2(z, Math.Sqrt(x * x + y * y)); double beta = CAACoordinateTransformation.RadiansToDegrees(betarad); //Step 6 details.DE = CAACoordinateTransformation.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 = CAACoordinateTransformation.DegreesToRadians(N); double ldash = l - 0.00697 / r; double ldashrad = CAACoordinateTransformation.DegreesToRadians(ldash); double bdash = b - 0.000225 * (Math.Cos(lrad - Nrad) / r); double bdashrad = CAACoordinateTransformation.DegreesToRadians(bdash); //Step 8 details.DS = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(-Math.Sin(Beta0rad) * Math.Sin(bdashrad) - Math.Cos(Beta0rad) * Math.Cos(bdashrad) * Math.Cos(Lambda0rad - ldashrad))); //Step 9 double W = CAACoordinateTransformation.MapTo0To360Range(11.504 + 350.89200025 * (JD - LightTravelTime - 2433282.5)); //Step 10 double e0 = CAANutation.MeanObliquityOfEcliptic(JD); double e0rad = CAACoordinateTransformation.DegreesToRadians(e0); CAA2DCoordinate PoleEquatorial = CAACoordinateTransformation.Ecliptic2Equatorial(Lambda0, Beta0, e0); double alpha0rad = CAACoordinateTransformation.HoursToRadians(PoleEquatorial.X); double delta0rad = CAACoordinateTransformation.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 = CAACoordinateTransformation.RadiansToHours(alpharad); double deltarad = Math.Atan2(v, Math.Sqrt(x * x + u * u)); double delta = CAACoordinateTransformation.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 = CAACoordinateTransformation.MapTo0To360Range(W - CAACoordinateTransformation.RadiansToDegrees(xi)); //Step 13 double NutationInLongitude = CAANutation.NutationInLongitude(JD); double NutationInObliquity = CAANutation.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; Lambda0rad = CAACoordinateTransformation.DegreesToRadians(Lambda0); lambda += NutationInLongitude / 3600; lambdarad = CAACoordinateTransformation.DegreesToRadians(lambda); e0 += NutationInObliquity / 3600; e0rad = CAACoordinateTransformation.DegreesToRadians(e0rad); //Step 16 CAA2DCoordinate ApparentPoleEquatorial = CAACoordinateTransformation.Ecliptic2Equatorial(Lambda0, Beta0, e0); double alpha0dash = CAACoordinateTransformation.HoursToRadians(ApparentPoleEquatorial.X); double delta0dash = CAACoordinateTransformation.DegreesToRadians(ApparentPoleEquatorial.Y); CAA2DCoordinate ApparentMars = CAACoordinateTransformation.Ecliptic2Equatorial(lambda, beta, e0); double alphadash = CAACoordinateTransformation.HoursToRadians(ApparentMars.X); double deltadash = CAACoordinateTransformation.DegreesToRadians(ApparentMars.Y); //Step 17 details.P = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.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 = CAASun.GeometricEclipticLongitude(JD); double SunBeta = CAASun.GeometricEclipticLatitude(JD); CAA2DCoordinate SunEquatorial = CAACoordinateTransformation.Ecliptic2Equatorial(SunLambda, SunBeta, e0); details.X = CAAMoonIlluminatedFraction.PositionAngle(SunEquatorial.X, SunEquatorial.Y, alpha, delta); //Step 19 details.d = 9.36 / DELTA; details.k = CAAIlluminatedFraction.IlluminatedFraction(r, R, DELTA); details.q = (1 - details.k) * details.d; return(details); }