]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGRotation.h
Sync. with JSBSim CVS.
[flightgear.git] / src / FDM / JSBSim / FGRotation.h
index d072bda1e1a46c677f3b081da1896b9e40cd9820..85ee9b2553e1d460b2e1beb126a01bdecafd235c 100644 (file)
@@ -27,24 +27,6 @@ HISTORY
 --------------------------------------------------------------------------------
 12/02/98   JSB   Created
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-COMMENTS, REFERENCES,  and NOTES
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
-    Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
-    School, January 1994
-[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
-    JSC 12960, July 1977
-[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
-    NASA-Ames", NASA CR-2497, January 1975
-[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
-    Wiley & Sons, 1979 ISBN 0-471-03032-5
-[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
-    1982 ISBN 0-471-08936-2
-
-  The order of rotations used in this class corresponds to a 3-2-1 sequence,
-  or Y-P-R, or Z-Y-X, if you prefer.
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -58,25 +40,50 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
-#    include <cmath>
-#  else
+#  include <math.h>
+#else
+#  if defined (sgi) && !defined(__GNUC__)
 #    include <math.h>
+#  else
+#    include <cmath>
 #  endif
-#else
-#  include <cmath>
-#endif
-
-#ifndef M_PI
-#  include <simgear/constants.h>
-#  define M_PI FG_PI
 #endif
 
 #include "FGModel.h"
-#include "FGMatrix.h"
+#include "FGColumnVector3.h"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #define ID_ROTATION "$Id$"
 
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+namespace JSBSim {
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Models the rotational portion of the Equations of Motion.
+    Note: The order of rotations used in this class corresponds to a 3-2-1 sequence,
+    or Y-P-R, or Z-Y-X, if you prefer.
+    @see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
+    Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
+    School, January 1994
+    @see D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
+    JSC 12960, July 1977
+    @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
+    NASA-Ames", NASA CR-2497, January 1975
+    @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
+    Wiley & Sons, 1979 ISBN 0-471-03032-5
+    @see Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
+    1982 ISBN 0-471-08936-2
+*/
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -89,44 +96,61 @@ public:
 
   bool Run(void);
 
-  inline FGColumnVector GetPQR(void) {return vPQR;}
-  inline FGColumnVector GetPQRdot(void) {return vPQRdot;}
-  inline FGColumnVector GetEuler(void) {return vEuler;}
-  inline FGColumnVector GetEulerRates(void) { return vEulerRates; }
-  inline void SetPQR(FGColumnVector tt) {vPQR = tt;}
-  inline void SetEuler(FGColumnVector tt) {vEuler = tt;}
-  
-  inline float Getphi(void) {return vEuler(1);}
-  inline float Gettht(void) {return vEuler(2);}
-  inline float Getpsi(void) {return vEuler(3);}
-  
-  inline float GetCosphi(void) {return cPhi;}
-  inline float GetCostht(void) {return cTht;}
-  inline float GetCospsi(void) {return cPsi;}
-
-  inline float GetSinphi(void) {return sPhi;}
-  inline float GetSintht(void) {return sTht;}
-  inline float GetSinpsi(void) {return sPsi;}
+  inline FGColumnVector3& GetPQR(void) {return vPQR;}
+  inline double GetPQR(int axis) const {return vPQR(axis);}
+  inline FGColumnVector3& GetAeroPQR(void) {return vAeroPQR;}
+  inline double GetAeroPQR(int axis) const {return vAeroPQR(axis);}
+  inline FGColumnVector3& GetPQRdot(void) {return vPQRdot;}
+  inline double GetPQRdot(int idx) const {return vPQRdot(idx);}
+  inline FGColumnVector3& GetEuler(void) {return vEuler;}
+  inline double GetEuler(int axis) const {return vEuler(axis);}
+  inline FGColumnVector3& GetEulerRates(void) { return vEulerRates; }
+  inline double GetEulerRates(int axis) const { return vEulerRates(axis); }
+  inline void SetPQR(FGColumnVector3 tt) {vPQR = tt;}
+  inline void SetPQR(double p, double q, double r) {vPQR(eP)=p;
+                                                    vPQR(eQ)=q;
+                                                    vPQR(eR)=r;}
+  inline void SetAeroPQR(FGColumnVector3 tt) {vAeroPQR = tt;}
+  inline void SetAeroPQR(double p, double q, double r) {vAeroPQR(eP)=p;
+                                                        vAeroPQR(eQ)=q;
+                                                        vAeroPQR(eR)=r;}
+  inline void SetEuler(FGColumnVector3 tt) {vEuler = tt;}
+
+  inline double Getphi(void) const {return vEuler(1);}
+  inline double Gettht(void) const {return vEuler(2);}
+  inline double Getpsi(void) const {return vEuler(3);}
+
+  inline double GetCosphi(void) const {return cPhi;}
+  inline double GetCostht(void) const {return cTht;}
+  inline double GetCospsi(void) const {return cPsi;}
+
+  inline double GetSinphi(void) const {return sPhi;}
+  inline double GetSintht(void) const {return sTht;}
+  inline double GetSinpsi(void) const {return sPsi;}
+
+  void bind(void);
+  void unbind(void);
 
 private:
-  FGColumnVector vPQR;
-  FGColumnVector vPQRdot;
-  FGColumnVector vMoments;
-  FGColumnVector vEuler;
-  FGColumnVector vEulerRates;
-  
-  float cTht,sTht;
-  float cPhi,sPhi;
-  float cPsi,sPsi;
-  
-  float Ixx, Iyy, Izz, Ixz;
-  float dt;
+  FGColumnVector3 vPQR;
+  FGColumnVector3 vAeroPQR;
+  FGColumnVector3 vPQRdot;
+  FGColumnVector3 vPQRdot_prev[4];
+  FGColumnVector3 vMoments;
+  FGColumnVector3 vEuler;
+  FGColumnVector3 vEulerRates;
+
+  double cTht,sTht;
+  double cPhi,sPhi;
+  double cPsi,sPsi;
+
+  double dt;
 
   void GetState(void);
 
-  void Debug(void);
+  void Debug(int from);
 };
-
+}
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 #endif