]> git.mxchange.org Git - simgear.git/commitdiff
Fixed a problem that could cause a divide by zero error during initialization.
authorcurt <curt>
Sun, 10 Jun 2001 15:12:09 +0000 (15:12 +0000)
committercurt <curt>
Sun, 10 Jun 2001 15:12:09 +0000 (15:12 +0000)
Contributed by Durk Talsma.

simgear/ephemeris/moonpos.cxx

index 27d62a733e1f1950a4be5be69ac4a8e28c77fc04..476969270ae45b8377b5777d8745dd9e386e9217 100644 (file)
@@ -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)