]> git.mxchange.org Git - flightgear.git/blob - JSBsim/FGState.h
842b5505984cc2f3580523d752dfc84628dac850
[flightgear.git] / JSBsim / FGState.h
1 /*******************************************************************************
2
3  Header:       FGState.h
4  Author:       Jon S. Berndt
5  Date started: 11/17/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 FUNCTIONAL DESCRIPTION
27 --------------------------------------------------------------------------------
28
29 Based on Flightgear code, which is based on LaRCSim. This class wraps all
30 global state variables (such as velocity, position, orientation, etc.).
31
32 HISTORY
33 --------------------------------------------------------------------------------
34 11/17/98   JSB   Created
35 *******************************************************************************/
36
37 /*******************************************************************************
38 SENTRY
39 *******************************************************************************/
40
41 #ifndef FGSTATE_H
42 #define FGSTATE_H
43
44 /*******************************************************************************
45 INCLUDES
46 *******************************************************************************/
47
48 #include <stdio.h>
49 #include <fstream.h>
50
51 /*******************************************************************************
52 DEFINES
53 *******************************************************************************/
54
55 /*******************************************************************************
56 CLASS DECLARATION
57 *******************************************************************************/
58
59 class FGState
60 {
61 public:
62    FGState(void);
63   ~FGState(void);
64
65   bool Reset(char*);
66   bool StoreData(char*);
67   bool DumpData(char*);
68   bool DisplayData(void);
69   
70   inline float GetU(void) {return U;}
71   inline float GetV(void) {return V;}
72   inline float GetW(void) {return W;}
73
74   inline float GetVn(void) {return Vn;}
75   inline float GetVe(void) {return Ve;}
76   inline float GetVd(void) {return Vd;}
77
78   inline float GetVt(void) {return Vt;}
79
80   inline float GetFx(void) {return Fx;}
81   inline float GetFy(void) {return Fy;}
82   inline float GetFz(void) {return Fz;}
83
84   inline float GetP(void) {return P;}
85   inline float GetQ(void) {return Q;}
86   inline float GetR(void) {return R;}
87
88   inline float GetQ0(void) {return Q0;}
89   inline float GetQ1(void) {return Q1;}
90   inline float GetQ2(void) {return Q2;}
91   inline float GetQ3(void) {return Q3;}
92
93   inline float GetL(void) {return L;}
94   inline float GetM(void) {return M;}
95   inline float GetN(void) {return N;}
96
97   inline float GetIxx(void) const {return Ixx;}
98   inline float GetIyy(void) const {return Iyy;}
99   inline float GetIzz(void) const {return Izz;}
100   inline float GetIxz(void) const {return Ixz;}
101
102   inline float Getlatitude(void) {return latitude;}
103   inline float Getlongitude(void) {return longitude;}
104   inline float GetGeodeticLat(void) {return GeodeticLat;}
105   
106   inline float Getalpha(void) {return alpha;}
107   inline float Getbeta(void) {return beta;}
108   inline float Getgamma(void) {return gamma;}
109
110   inline float Getadot(void) {return adot;}
111   inline float Getbdot(void) {return bdot;}
112   
113   inline float GetUdot(void) {return Udot;}
114   inline float GetVdot(void) {return Vdot;}
115   inline float GetWdot(void) {return Wdot;}
116
117   inline float GetPdot(void) {return Pdot;}
118   inline float GetQdot(void) {return Qdot;}
119   inline float GetRdot(void) {return Rdot;}
120
121   inline float Geth(void) {return h;}
122   inline float Geta(void) {return a;}
123   inline float GetMach(void) {return Mach;}
124   
125   inline float Getrho(void) {return rho;}
126   inline float Getsim_time(void) {return sim_time;}
127   inline float Getdt(void) {return dt;}
128
129   inline float Getphi(void) {return phi;}
130   inline float Gettht(void) {return tht;}
131   inline float Getpsi(void) {return psi;}
132
133   inline float Getg(void) {return g;}
134   inline float Getm(void) {return m;}
135
136   inline float Getqbar(void) {return qbar;}
137   inline float GetT(int r, int c) {return T[r][c];}
138
139   inline void SetU(float tt) {U = tt;}
140   inline void SetV(float tt) {V = tt;}
141   inline void SetW(float tt) {W = tt;}
142
143   inline void SetVt(float tt) {Vt = tt;}
144
145   inline void SetVn(float tt) {Vn = tt;}
146   inline void SetVe(float tt) {Ve = tt;}
147   inline void SetVd(float tt) {Vd = tt;}
148
149   inline void SetFx(float tt) {Fx = tt;}
150   inline void SetFy(float tt) {Fy = tt;}
151   inline void SetFz(float tt) {Fz = tt;}
152
153   inline void SetP(float tt) {P = tt;}
154   inline void SetQ(float tt) {Q = tt;}
155   inline void SetR(float tt) {R = tt;}
156
157   inline void SetL(float tt) {L = tt;}
158   inline void SetM(float tt) {M = tt;}
159   inline void SetN(float tt) {N = tt;}
160
161   inline void SetIxx(float tt) {Ixx = tt;}
162   inline void SetIyy(float tt) {Iyy = tt;}
163   inline void SetIzz(float tt) {Izz = tt;}
164   inline void SetIxz(float tt) {Ixz = tt;}
165
166   inline void Setlatitude(float tt) {latitude = tt;}
167   inline void Setlongitude(float tt) {longitude = tt;}
168   inline void SetGeodeticLat(float tt) {GeodeticLat = tt;}
169
170   inline void Setalpha(float tt) {alpha = tt;}
171   inline void Setbeta(float tt) {beta = tt;}
172   inline void Setgamma(float tt) {gamma = tt;}
173
174   inline void Setadot(float tt) {adot = tt;}
175   inline void Setbdot(float tt) {bdot = tt;}
176
177   inline void SetUdot(float tt) {Udot = tt;}
178   inline void SetVdot(float tt) {Vdot = tt;}
179   inline void SetWdot(float tt) {Wdot = tt;}
180
181   inline void SetPdot(float tt) {Pdot = tt;}
182   inline void SetQdot(float tt) {Qdot = tt;}
183   inline void SetRdot(float tt) {Rdot = tt;}
184
185   inline void Setphi(float tt) {phi = tt;}
186   inline void Settht(float tt) {tht = tt;}
187   inline void Setpsi(float tt) {psi = tt;}
188
189   inline void Setg(float tt) {g = tt;}
190   inline void Setm(float tt) {m = tt;}
191   inline void Setqbar(float tt) {qbar = tt;}
192
193   inline void Seth(float tt) {h = tt;}
194   inline void Seta(float tt) {a = tt;}
195   inline void SetMach(float tt) {Mach = tt;}
196
197   inline void Setrho(float tt) {rho = tt;}
198   inline float Setsim_time(float tt) {sim_time = tt; return sim_time;}
199   inline void Setdt(float tt) {dt = tt;}
200   inline void SetQ0123(float q0, float q1, float q2, float q3) {Q0=q0;Q1=q1;Q2=q2;Q3=q3;}
201   inline void SetT(int r, int c, float tt) {T[r][c] = tt;}
202
203   inline float IncrTime(void) {sim_time+=dt;return sim_time;}
204
205   const float EarthRad;
206
207 private:
208
209   float U, V, W, Fx, Fy, Fz;        // A/C body axis velocities and forces
210   float P, Q, R, L, M, N;           // A/C body axis rates and moments
211   float Q0, Q1, Q2, Q3;             // Quaternion elements
212   float Ixx, Iyy, Izz, Ixz;         // Moments of Inertia
213   float Vt;                         // Total velocity
214   float Vn, Ve, Vd;                 // North, East, and Down local velocities
215   float latitude, longitude;        // position
216   float GeodeticLat;                // Geodetic Latitude
217   float alpha, beta, gamma;         // angle of attack, sideslip, and roll
218   float adot, bdot;                 // alpha dot and beta dot
219   float phi, tht, psi;              // Euler angles
220   float Udot, Vdot, Wdot;           // A/C body axis accelerations
221   float Pdot, Qdot, Rdot;           // A/C body axis rotational accelerations
222   float h, a;                       // altitude above sea level, speed of sound
223   float rho, qbar;                  // density of air in lb/ft^3, dynamic pressure
224   float sim_time, dt;
225   float m, g;                       // mass and acceleration of gravity
226   float T[4][4];                    // Local to Body transformation matrix
227   float Mach;                       // Mach number
228
229 protected:
230
231
232 };
233
234 #ifndef FDM_MAIN
235 extern FGState* State;
236 #else
237 FGState* State;
238 #endif
239
240 /******************************************************************************/
241 #endif