]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGCoefficient.h
Updated for both JSBsim and Tony Peden's c172 flight model.
[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_I2VEL    65536L
79
80 /*******************************************************************************
81 FORWARD DECLARATIONS
82 *******************************************************************************/
83 class FGFDMExec;
84 class FGState;
85 class FGAtmosphere;
86 class FGFCS;
87 class FGAircraft;
88 class FGTranslation;
89 class FGRotation;
90 class FGPosition;
91 class FGAuxiliary;
92 class FGOutput;
93
94 /*******************************************************************************
95 COMMENTS, REFERENCES,  and NOTES
96 ********************************************************************************
97
98 This class models the stability derivative coefficient lookup tables or 
99 equations. Note that the coefficients need not be calculated each delta-t.
100
101 FG_QBAR         1
102 FG_WINGAREA     2
103 FG_WINGSPAN     4
104 FG_CBAR         8
105 FG_ALPHA       16
106 FG_ALPHADOT    32
107 FG_BETA        64
108 FG_BETADOT    128
109 FG_PITCHRATE  256
110 FG_ROLLRATE   512
111 FG_YAWRATE   1024
112 FG_ELEVATOR  2048
113 FG_AILERON   4096
114 FG_RUDDER    8192
115 FG_MACH     16384
116 FG_ALTITUDE 32768L
117 FG_I2VEL    65536L
118
119 ********************************************************************************
120 CLASS DECLARATION
121 *******************************************************************************/
122
123 class FGCoefficient
124 {
125 public:
126   FGCoefficient(FGFDMExec*, ifstream&);
127   ~FGCoefficient(void);
128   bool Allocate(int);
129   bool Allocate(int, int);
130   float Value(float, float);
131   float Value(float);
132   float Value(void);
133   float TotalValue(void);
134   enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
135
136 protected:
137
138 private:
139   typedef map<string, long> CoeffMap;
140   CoeffMap coeffdef;
141   string filename;
142   string description;
143   string name;
144   string method;
145   float StaticValue;
146   float *Table2D;
147   float **Table3D;
148   float LookupR, LookupC;
149   long int mult_idx[10];
150   int rows, columns;
151   Type type;
152   int multipliers;
153   int mult_count;
154
155   float GetCoeffVal(int);
156
157   FGFDMExec*      FDMExec;
158   FGState*        State;
159   FGAtmosphere*   Atmosphere;
160   FGFCS*          FCS;
161   FGAircraft*     Aircraft;
162   FGTranslation*  Translation;
163   FGRotation*     Rotation;
164   FGPosition*     Position;
165   FGAuxiliary*    Auxiliary;
166   FGOutput*       Output;
167 };
168
169 /******************************************************************************/
170 #endif