]> git.mxchange.org Git - flightgear.git/commitdiff
Bug fix for the issue #1497. JSBSim calculations of geodetic coordinates were produci...
authorbcoconni <bcoconni@users.sourceforge.net>
Sun, 3 Aug 2014 11:59:30 +0000 (13:59 +0200)
committerbcoconni <bcoconni@users.sourceforge.net>
Sun, 3 Aug 2014 11:59:30 +0000 (13:59 +0200)
src/FDM/JSBSim/math/FGLocation.cpp

index 88a1946b7a705c3766e39d627aec4527b2afbdf2..da418394435c4e73f04d3b6e0d59d26d0305c3b6 100644 (file)
@@ -419,7 +419,15 @@ void FGLocation::ComputeDerivedUnconditional(void) const
         z  = signz0*sqrt_q*(w+sqrt(z_term));
       }
       Ne = a*sqrt(1+eps2*z*z/b2);
-      mGeodLat = asin((eps2+1.0)*(z/Ne));
+      double tmp = (eps2+1.0)*(z/Ne);
+      // Ugly hack to work around the round-off errors when the simulation is
+      // started at a latitude of 90deg.
+      if (tmp > 1.0)
+        tmp = 1.0;
+      else if (tmp < -1.0)
+        tmp = -1.0;
+      // End of ugly hack
+      mGeodLat = asin(tmp);
       r0 = rxy;
       GeodeticAltitude = r0*cos(mGeodLat) + mECLoc(eZ)*sin(mGeodLat) - a2/Ne;
     }