]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGState.cpp
Fixes to jsbsim.
[flightgear.git] / src / FDM / JSBSim / FGState.cpp
index 15583cb2c724b90d927ef195710291b0f26a5014..285d844c09ecd9eb3145ad69a6378f354f11f466 100644 (file)
@@ -47,6 +47,11 @@ INCLUDES
 #  include <cmath>
 #endif
 
+#ifndef M_PI         // support for silly Microsoft compiler
+#  include <simgear/constants.h>
+#  define M_PI FG_PI
+#endif 
+
 #include "FGState.h"
 #include "FGFDMExec.h"
 #include "FGAtmosphere.h"
@@ -456,13 +461,12 @@ void FGState::IntegrateQuat(FGColumnVector vPQR, int rate) {
 FGColumnVector FGState::CalcEuler(void) {
   static FGColumnVector vEuler(3);
 
-  if (mTl2b(3,3) == 0)    vEuler(ePhi) = 0.0;
-  else                    vEuler(ePhi) = atan2(mTl2b(2,3), mTl2b(3,3));
+  if (mTl2b(3,3) == 0.0) mTl2b(3,3) = 0.0000001;
+  if (mTl2b(1,1) == 0.0) mTl2b(1,1) = 0.0000001;
 
+  vEuler(ePhi) = atan2(mTl2b(2,3), mTl2b(3,3));
   vEuler(eTht) = asin(-mTl2b(1,3));
-
-  if (mTl2b(1,1) == 0.0)  vEuler(ePsi) = 0.0;
-  else                    vEuler(ePsi) = atan2(mTl2b(1,2), mTl2b(1,1));
+  vEuler(ePsi) = atan2(mTl2b(1,2), mTl2b(1,1));
 
   if (vEuler(ePsi) < 0.0) vEuler(ePsi) += 2*M_PI;