From a212589865a5a59f93778e4543e7a09e39ce9107 Mon Sep 17 00:00:00 2001 From: curt Date: Sun, 10 Jun 2001 15:12:09 +0000 Subject: [PATCH] Fixed a problem that could cause a divide by zero error during initialization. Contributed by Durk Talsma. --- simgear/ephemeris/moonpos.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/simgear/ephemeris/moonpos.cxx b/simgear/ephemeris/moonpos.cxx index 27d62a73..47696927 100644 --- a/simgear/ephemeris/moonpos.cxx +++ b/simgear/ephemeris/moonpos.cxx @@ -182,7 +182,17 @@ void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun) // 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); + 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) -- 2.39.5