]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBsim/FGRotation.h
source tree reorganization prior to flightgear 0.7
[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 <Include/compiler.h>
61 #  ifdef FG_HAVE_STD_INCLUDES
62 #    include <cmath>
63 #  else
64 #    include <math.h>
65 #  endif
66 #else
67 #  include <cmath>
68 #endif
69
70 #include "FGModel.h"
71
72 using namespace std;
73
74 /*******************************************************************************
75 CLASS DECLARATION
76 *******************************************************************************/
77
78 class FGRotation : public FGModel
79 {
80 public:
81   FGRotation(FGFDMExec*);
82   ~FGRotation(void);
83
84   bool Run(void);
85
86   inline float GetP(void) {return P;}
87   inline float GetQ(void) {return Q;}
88   inline float GetR(void) {return R;}
89
90   inline float GetPdot(void) {return Pdot;}
91   inline float GetQdot(void) {return Qdot;}
92   inline float GetRdot(void) {return Rdot;}
93
94   inline float Getphi(void) {return phi;}
95   inline float Gettht(void) {return tht;}
96   inline float Getpsi(void) {return psi;}
97
98   inline float GetQ0(void) {return Q0;}
99   inline float GetQ1(void) {return Q1;}
100   inline float GetQ2(void) {return Q2;}
101   inline float GetQ3(void) {return Q3;}
102
103   inline void SetP(float tt) {P = tt;}
104   inline void SetQ(float tt) {Q = tt;}
105   inline void SetR(float tt) {R = tt;}
106
107   inline void SetPQR(float t1, float t2, float t3) {P=t1;
108                                                     Q=t2;
109                                                     R=t3;}
110
111   inline void Setphi(float tt) {phi = tt;}
112   inline void Settht(float tt) {tht = tt;}
113   inline void Setpsi(float tt) {psi = tt;}
114
115   inline void SetEuler(float t1, float t2, float t3) {phi=t1;
116                                                       tht=t2;
117                                                       psi=t3;}
118
119   inline void SetQ0123(float t1, float t2, float t3, float t4) {Q0=t1;
120                                                                 Q1=t2;
121                                                                 Q2=t3;
122                                                                 Q3=t4;}
123
124 protected:
125
126 private:
127   float P, Q, R;
128   float L, M, N;
129   float Ixx, Iyy, Izz, Ixz;
130   float Q0, Q1, Q2, Q3;
131   float phi, tht, psi;
132   float Pdot, Qdot, Rdot;
133   float Q0dot, Q1dot, Q2dot, Q3dot;
134   float lastPdot, lastQdot, lastRdot;
135   float lastQ0dot, lastQ1dot, lastQ2dot, lastQ3dot;
136   float dt;
137   float T[4][4];
138
139   void GetState(void);
140   void PutState(void);
141 };
142
143 /******************************************************************************/
144 #endif