]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGRotation.h
Synced with latest JSBSim cvs.
[flightgear.git] / src / FDM / JSBSim / FGRotation.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGRotation.h
4  Author:       Jon Berndt
5  Date started: 12/02/98
6
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  details.
18
19  You should have received a copy of the GNU General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28 12/02/98   JSB   Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 COMMENTS, REFERENCES,  and NOTES
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 [1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
34     Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
35     School, January 1994
36 [2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
37     JSC 12960, July 1977
38 [3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
39     NASA-Ames", NASA CR-2497, January 1975
40 [4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
41     Wiley & Sons, 1979 ISBN 0-471-03032-5
42 [5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
43     1982 ISBN 0-471-08936-2
44
45   The order of rotations used in this class corresponds to a 3-2-1 sequence,
46   or Y-P-R, or Z-Y-X, if you prefer.
47
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 SENTRY
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51
52 #ifndef FGROTATION_H
53 #define FGROTATION_H
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 INCLUDES
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 #ifdef FGFS
60 #  include <simgear/compiler.h>
61 #  include <math.h>
62 #else
63 #  if defined (sgi) && !defined(__GNUC__)
64 #    include <math.h>
65 #  else
66 #    include <cmath>
67 #  endif
68 #endif
69
70 #include "FGModel.h"
71 #include "FGMatrix33.h"
72 #include "FGColumnVector3.h"
73 #include "FGColumnVector4.h"
74
75 #define ID_ROTATION "$Id$"
76
77 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 CLASS DECLARATION
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
80
81 class FGRotation : public FGModel
82 {
83 public:
84   FGRotation(FGFDMExec*);
85   ~FGRotation();
86
87   bool Run(void);
88
89   inline FGColumnVector3& GetPQR(void) {return vPQR;}
90   inline double GetPQR(int axis) {return vPQR(axis);}
91   inline FGColumnVector3& GetPQRdot(void) {return vPQRdot;}
92   inline double GetPQRdot(int idx) {return vPQRdot(idx);}
93   inline FGColumnVector3& GetEuler(void) {return vEuler;}
94   inline double GetEuler(int axis) {return vEuler(axis);}
95   inline FGColumnVector3& GetEulerRates(void) { return vEulerRates; }
96   inline double GetEulerRates(int axis) { return vEulerRates(axis); }
97   inline void SetPQR(FGColumnVector3 tt) {vPQR = tt;}
98   inline void SetEuler(FGColumnVector3 tt) {vEuler = tt;}
99   
100   inline double Getphi(void) {return vEuler(1);}
101   inline double Gettht(void) {return vEuler(2);}
102   inline double Getpsi(void) {return vEuler(3);}
103   
104   inline double GetCosphi(void) {return cPhi;}
105   inline double GetCostht(void) {return cTht;}
106   inline double GetCospsi(void) {return cPsi;}
107
108   inline double GetSinphi(void) {return sPhi;}
109   inline double GetSintht(void) {return sTht;}
110   inline double GetSinpsi(void) {return sPsi;}
111
112 private:
113   FGColumnVector3 vPQR;
114   FGColumnVector3 vPQRdot;
115   FGColumnVector3 vMoments;
116   FGColumnVector3 vEuler;
117   FGColumnVector3 vEulerRates;
118   FGColumnVector3 vlastPQRdot;
119   
120   double cTht,sTht;
121   double cPhi,sPhi;
122   double cPsi,sPsi;
123   
124   double Ixx, Iyy, Izz, Ixz;
125   double dt;
126
127   void GetState(void);
128
129   void Debug(void);
130 };
131
132 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133 #endif
134