]> git.mxchange.org Git - flightgear.git/blob - JSBsim/FGCoefficient.h
MSVC++ portability tweaks contributed by Bernie Bright.
[flightgear.git] / 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 /*******************************************************************************
55 DEFINES
56 *******************************************************************************/
57 #define FG_QBAR         1
58 #define FG_WINGAREA     2
59 #define FG_WINGSPAN     4
60 #define FG_CBAR         8
61 #define FG_ALPHA       16
62 #define FG_ALPHADOT    32
63 #define FG_BETA        64
64 #define FG_BETADOT    128
65 #define FG_PITCHRATE  256
66 #define FG_ROLLRATE   512
67 #define FG_YAWRATE   1024
68 #define FG_ELEVATOR  2048
69 #define FG_AILERON   4096
70 #define FG_RUDDER    8192
71 #define FG_MACH     16384
72 #define FG_ALTITUDE 32768L
73
74 /*******************************************************************************
75 FORWARD DECLARATIONS
76 *******************************************************************************/
77 class FGFDMExec;
78 class FGState;
79 class FGAtmosphere;
80 class FGFCS;
81 class FGAircraft;
82 class FGTranslation;
83 class FGRotation;
84 class FGPosition;
85 class FGAuxiliary;
86 class FGOutput;
87
88 /*******************************************************************************
89 COMMENTS, REFERENCES,  and NOTES
90 *******************************************************************************/
91 /**
92 This class models the stability derivative coefficient lookup tables or 
93 equations. Note that the coefficients need not be calculated each delta-t.
94
95 The coefficient files are located in the axis subdirectory for each aircraft.
96 For instance, for the X-15, you would find subdirectories under the
97 aircraft/X-15/ directory named CLIFT, CDRAG, CSIDE, CROLL, CPITCH, CYAW. Under
98 each of these directories would be files named a, a0, q, and so on. The file
99 named "a" under the CLIFT directory would contain data for the stability
100 derivative modeling lift due to a change in alpha. See the FGAircraft.cpp file
101 for additional information. The coefficient files have the following format:
102
103 <name of coefficient>
104 <short description of coefficient with no embedded spaces>
105 <method used in calculating the coefficient: TABLE | EQUATION | VECTOR | VALUE>
106   <parameter identifier for table row (if required)>
107   <parameter identifier for table column (if required)>
108 <OR'ed list of parameter identifiers needed to turn this coefficient into a force>
109 <number of rows in table (if required)>
110 <number of columns in table (if required)>
111
112 <value of parameter indexing into the column of a table or vector - or value
113   itself for a VALUE coefficient>
114 <values of parameter indexing into row of a table if TABLE type> <Value of
115   coefficient at this row and column>
116
117 <... repeat above for each column of data in table ...>
118
119 As an example for the X-15, for the lift due to mach:
120 <PRE>
121
122 CLa0
123 Lift_at_zero_alpha
124 Table 8 3
125 16384
126 32768
127 16387
128
129 0.00
130 0.0 0.0
131 0.5 0.4
132 0.9 0.9
133 1.0 1.6
134 1.1 1.3
135 1.4 1.0
136 2.0 0.5
137 3.0 0.5
138
139 30000.00
140 0.0 0.0
141 0.5 0.5
142 0.9 1.0
143 1.0 1.7
144 1.1 1.4
145 1.4 1.1
146 2.0 0.6
147 3.0 0.6
148
149 70000.00
150 0.0 0.0
151 0.5 0.6
152 0.9 1.1
153 1.0 1.7
154 1.1 1.5
155 1.4 1.2
156 2.0 0.7
157 3.0 0.7
158 </PRE>
159
160 Note that the values in a row which index into the table must be the same value
161 for each column of data, so the first column of numbers for each altitude are
162 seen to be equal, and there are the same number of values for each altitude.
163
164 <PRE>
165 FG_QBAR         1
166 FG_WINGAREA     2
167 FG_WINGSPAN     4
168 FG_CBAR         8
169 FG_ALPHA       16
170 FG_ALPHADOT    32
171 FG_BETA        64
172 FG_BETADOT    128
173 FG_PITCHRATE  256
174 FG_ROLLRATE   512
175 FG_YAWRATE   1024
176 FG_ELEVATOR  2048
177 FG_AILERON   4096
178 FG_RUDDER    8192
179 FG_MACH     16384
180 FG_ALTITUDE 32768L
181 </PRE>
182 @author Jon S. Berndt
183 @memo This class models the stability derivative coefficient lookup tables or equations.
184 */
185 /*******************************************************************************
186 CLASS DECLARATION
187 *******************************************************************************/
188
189 class FGCoefficient
190 {
191 public:
192   // ***************************************************************************
193   /** @memo Constructor
194       @param FGFDMExec* - pointer to owning simulation executive
195   */
196   FGCoefficient(FGFDMExec*);
197
198   // ***************************************************************************
199   /** @memo Constructor for two independent variable table
200       @param
201       @return
202   */
203   FGCoefficient(FGFDMExec*, int, int);
204
205   // ***************************************************************************
206   /** @memo
207       @param
208       @return
209   */
210   FGCoefficient(FGFDMExec*, int);
211
212   // ***************************************************************************
213   /** @memo
214       @param
215       @return
216   */
217   FGCoefficient(FGFDMExec*, string);
218
219   // ***************************************************************************
220   /** @memo
221       @param
222       @return
223   */
224   ~FGCoefficient(void);
225
226   // ***************************************************************************
227   /** @memo
228       @param
229       @return
230   */
231   bool Allocate(int);
232
233   // ***************************************************************************
234   /** @memo
235       @param
236       @return
237   */
238   bool Allocate(int, int);
239
240   // ***************************************************************************
241   /** @memo
242       @param
243       @return
244   */
245   float Value(float, float);
246
247   // ***************************************************************************
248   /** @memo
249       @param
250       @return
251   */
252   float Value(float);
253
254   // ***************************************************************************
255   /** @memo
256       @param
257       @return
258   */
259   float Value(void);
260
261   // ***************************************************************************
262   /** @memo
263       @param
264       @return
265   */
266   enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
267
268 protected:
269
270 private:
271   string filename;
272   string description;
273   string name;
274   string method;
275   float StaticValue;
276   float *Table2D;
277   float **Table3D;
278   float LookupR, LookupC;
279   long int mult_idx[10];
280   int rows, columns;
281   Type type;
282   int multipliers;
283   int mult_count;
284
285   float GetCoeffVal(int);
286
287   FGFDMExec*      FDMExec;
288   FGState*        State;
289   FGAtmosphere*   Atmosphere;
290   FGFCS*          FCS;
291   FGAircraft*     Aircraft;
292   FGTranslation*  Translation;
293   FGRotation*     Rotation;
294   FGPosition*     Position;
295   FGAuxiliary*    Auxiliary;
296   FGOutput*       Output;
297 };
298
299 /******************************************************************************/
300 #endif