]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBsim/FGCoefficient.h
c937c54a657d472f48c914eebb94e970e0632ccf
[flightgear.git] / src / FDM / JSBsim / FGCoefficient.h
1 /*******************************************************************************
2
3  Header:       FGCoefficient.h
4  Author:       Jon Berndt
5  Date started: 12/28/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/28/98   JSB   Created
29
30 ********************************************************************************
31 SENTRY
32 *******************************************************************************/
33
34 #ifndef FGCOEFFICIENT_H
35 #define FGCOEFFICIENT_H
36
37 /*******************************************************************************
38 INCLUDES
39 *******************************************************************************/
40 #ifdef FGFS
41 #  include <Include/compiler.h>
42 #  include STL_STRING
43 #  ifdef FG_HAVE_STD_INCLUDES
44 #    include <fstream>
45 #  else
46 #    include <fstream.h>
47 #  endif
48    FG_USING_STD(string);
49 #else
50 #  include <string>
51 #  include <fstream>
52 #endif
53
54 #include <map>
55
56 /*******************************************************************************
57 DEFINES
58 *******************************************************************************/
59
60 using namespace std;
61
62 #define FG_QBAR         1
63 #define FG_WINGAREA     2
64 #define FG_WINGSPAN     4
65 #define FG_CBAR         8
66 #define FG_ALPHA       16
67 #define FG_ALPHADOT    32
68 #define FG_BETA        64
69 #define FG_BETADOT    128
70 #define FG_PITCHRATE  256
71 #define FG_ROLLRATE   512
72 #define FG_YAWRATE   1024
73 #define FG_ELEVATOR  2048
74 #define FG_AILERON   4096
75 #define FG_RUDDER    8192
76 #define FG_MACH     16384
77 #define FG_ALTITUDE 32768L
78 #define FG_BI2VEL   65536L
79 #define FG_CI2VEL  131072L
80
81 /*******************************************************************************
82 FORWARD DECLARATIONS
83 *******************************************************************************/
84 class FGFDMExec;
85 class FGState;
86 class FGAtmosphere;
87 class FGFCS;
88 class FGAircraft;
89 class FGTranslation;
90 class FGRotation;
91 class FGPosition;
92 class FGAuxiliary;
93 class FGOutput;
94
95 /*******************************************************************************
96 COMMENTS, REFERENCES,  and NOTES
97 ********************************************************************************
98
99 This class models the stability derivative coefficient lookup tables or 
100 equations. Note that the coefficients need not be calculated each delta-t.
101
102 FG_QBAR         1
103 FG_WINGAREA     2
104 FG_WINGSPAN     4
105 FG_CBAR         8
106 FG_ALPHA       16
107 FG_ALPHADOT    32
108 FG_BETA        64
109 FG_BETADOT    128
110 FG_PITCHRATE  256
111 FG_ROLLRATE   512
112 FG_YAWRATE   1024
113 FG_ELEVATOR  2048
114 FG_AILERON   4096
115 FG_RUDDER    8192
116 FG_MACH     16384
117 FG_ALTITUDE 32768L
118 FG_BI2VEL   65536L
119 FG_CI2VEL  131072L
120
121 ********************************************************************************
122 CLASS DECLARATION
123 *******************************************************************************/
124
125 class FGCoefficient
126 {
127 public:
128   FGCoefficient(FGFDMExec*, ifstream&);
129   ~FGCoefficient(void);
130   bool Allocate(int);
131   bool Allocate(int, int);
132   float Value(float, float);
133   float Value(float);
134   float Value(void);
135   float TotalValue(void);
136   enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
137
138 protected:
139
140 private:
141   typedef map<string, long> CoeffMap;
142   CoeffMap coeffdef;
143   string filename;
144   string description;
145   string name;
146   string method;
147   float StaticValue;
148   float *Table2D;
149   float **Table3D;
150   float LookupR, LookupC;
151   long int mult_idx[10];
152   int rows, columns;
153   Type type;
154   int multipliers;
155   int mult_count;
156
157   float GetCoeffVal(int);
158
159   FGFDMExec*      FDMExec;
160   FGState*        State;
161   FGAtmosphere*   Atmosphere;
162   FGFCS*          FCS;
163   FGAircraft*     Aircraft;
164   FGTranslation*  Translation;
165   FGRotation*     Rotation;
166   FGPosition*     Position;
167   FGAuxiliary*    Auxiliary;
168   FGOutput*       Output;
169 };
170
171 /******************************************************************************/
172 #endif