X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fephemeris%2Fmoonpos.cxx;h=476969270ae45b8377b5777d8745dd9e386e9217;hb=a0bdec284624820feb0a96a06c0c38e2f07d5e4e;hp=4a348316972688d950b2575d563d77ecf8ed7b4d;hpb=0e8c0106451afb543b9c4d4a74abdc90f09141e3;p=simgear.git diff --git a/simgear/ephemeris/moonpos.cxx b/simgear/ephemeris/moonpos.cxx index 4a348316..47696927 100644 --- a/simgear/ephemeris/moonpos.cxx +++ b/simgear/ephemeris/moonpos.cxx @@ -27,7 +27,6 @@ #include #include -#include #ifdef __BORLANDC__ # define exception c_exception @@ -92,7 +91,7 @@ void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun) // calculate the angle between ecliptic and equatorial coordinate system // in Radians - ecl = ((DEG_TO_RAD * 23.4393) - (DEG_TO_RAD * 3.563E-7) * actTime); + ecl = ((SGD_DEGREES_TO_RADIANS * 23.4393) - (SGD_DEGREES_TO_RADIANS * 3.563E-7) * actTime); eccAnom = sgCalcEccAnom(M, e); // Calculate the eccentric anomaly xv = a * (cos(eccAnom) - e); yv = a * (sqrt(1.0 - e*e) * sin(eccAnom)); @@ -116,7 +115,7 @@ void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun) D = Lm - Ls; F = Lm - N; - lonEcl += DEG_TO_RAD * (-1.274 * sin (M - 2*D) + lonEcl += SGD_DEGREES_TO_RADIANS * (-1.274 * sin (M - 2*D) +0.658 * sin (2*D) -0.186 * sin(ourSun->getM()) -0.059 * sin(2*M - 2*D) @@ -129,7 +128,7 @@ void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun) -0.015 * sin(2*F - 2*D) +0.011 * sin(M - 4*D) ); - latEcl += DEG_TO_RAD * (-0.173 * sin(F-2*D) + latEcl += SGD_DEGREES_TO_RADIANS * (-0.173 * sin(F-2*D) -0.055 * sin(M - F - 2*D) -0.046 * sin(M + F - 2*D) +0.033 * sin(F + 2*D) @@ -138,7 +137,7 @@ void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun) r += (-0.58 * cos(M - 2*D) -0.46 * cos(2*D) ); - // FG_LOG(FG_GENERAL, FG_INFO, "Running moon update"); + // SG_LOG(SG_GENERAL, SG_INFO, "Running moon update"); xg = r * cos(lonEcl) * cos(latEcl); yg = r * sin(lonEcl) * cos(latEcl); zg = r * sin(latEcl); @@ -150,9 +149,9 @@ void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun) geoRa = atan2(ye, xe); geoDec = atan2(ze, sqrt(xe*xe + ye*ye)); - /* FG_LOG( FG_GENERAL, FG_INFO, - "(geocentric) geoRa = (" << (RAD_TO_DEG * geoRa) - << "), geoDec= (" << (RAD_TO_DEG * geoDec) << ")" ); */ + /* SG_LOG( SG_GENERAL, SG_INFO, + "(geocentric) geoRa = (" << (SGD_RADIANS_TO_DEGREES * geoRa) + << "), geoDec= (" << (SGD_RADIANS_TO_DEGREES * geoDec) << ")" ); */ // Given the moon's geocentric ra and dec, calculate its @@ -162,30 +161,40 @@ void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun) // First calculate the moon's parrallax, that is, the apparent size of the // (equatorial) radius of the earth, as seen from the moon mpar = asin ( 1 / r); - // FG_LOG( FG_GENERAL, FG_INFO, "r = " << r << " mpar = " << mpar ); - // FG_LOG( FG_GENERAL, FG_INFO, "lat = " << f->get_Latitude() ); + // SG_LOG( SG_GENERAL, SG_INFO, "r = " << r << " mpar = " << mpar ); + // SG_LOG( SG_GENERAL, SG_INFO, "lat = " << f->get_Latitude() ); gclat = lat - 0.003358 * - sin (2 * DEG_TO_RAD * lat ); - // FG_LOG( FG_GENERAL, FG_INFO, "gclat = " << gclat ); + sin (2 * SGD_DEGREES_TO_RADIANS * lat ); + // SG_LOG( SG_GENERAL, SG_INFO, "gclat = " << gclat ); - rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * lat); - // FG_LOG( FG_GENERAL, FG_INFO, "rho = " << rho ); + rho = 0.99883 + 0.00167 * cos(2 * SGD_DEGREES_TO_RADIANS * lat); + // SG_LOG( SG_GENERAL, SG_INFO, "rho = " << rho ); if (geoRa < 0) geoRa += (2*SGD_PI); HA = lst - (3.8197186 * geoRa); - /* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst() + /* SG_LOG( SG_GENERAL, SG_INFO, "t->getLst() = " << t->getLst() << " HA = " << HA ); */ g = atan (tan(gclat) / cos ((HA / 3.8197186))); - // FG_LOG( FG_GENERAL, FG_INFO, "g = " << g ); + // SG_LOG( SG_GENERAL, SG_INFO, "g = " << g ); rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec); - declination = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g); - - /* FG_LOG( FG_GENERAL, FG_INFO, - "Ra = (" << (RAD_TO_DEG *rightAscension) - << "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); */ + if (fabs(lat) > 0) { + declination + = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g); + } else { + declination = geoDec; + // cerr << "Geocentric vs. Topocentric position" << endl; + // cerr << "RA (difference) : " + // << SGD_RADIANS_TO_DEGREES * (geoRa - rightAscension) << endl; + // cerr << "Dec (difference) : " + // << SGD_RADIANS_TO_DEGREES * (geoDec - declination) << endl; + } + + /* SG_LOG( SG_GENERAL, SG_INFO, + "Ra = (" << (SGD_RADIANS_TO_DEGREES *rightAscension) + << "), Dec= (" << (SGD_RADIANS_TO_DEGREES *declination) << ")" ); */ }