]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Airplane.hpp
Moved JSBSim.hxx to src/FDM/JSBSim/
[flightgear.git] / src / FDM / YASim / Airplane.hpp
1 #ifndef _AIRPLANE_HPP
2 #define _AIRPLANE_HPP
3
4 #include "ControlMap.hpp"
5 #include "Model.hpp"
6 #include "Wing.hpp"
7 #include "Vector.hpp"
8
9 namespace yasim {
10
11 class Gear;
12 class Thruster;
13
14 class Airplane {
15 public:
16     Airplane();
17     ~Airplane();
18
19     void iterate(float dt);
20
21     ControlMap* getControlMap();
22     Model* getModel();
23
24     void setPilotPos(float* pos);
25     void getPilotPos(float* out);
26
27     void getPilotAccel(float* out);
28
29     void setWeight(float weight);
30
31     void setWing(Wing* wing);
32     void setTail(Wing* tail);
33     void addVStab(Wing* vstab);
34
35     void addFuselage(float* front, float* back, float width,
36                      float taper=1, float mid=0.5);
37     int addTank(float* pos, float cap, float fuelDensity);
38     void addGear(Gear* g, float transitionTime);
39     void addThruster(Thruster* t, float mass, float* cg);
40     void addBallast(float* pos, float mass);
41
42     int addWeight(float* pos, float size);
43     void setWeight(int handle, float mass);
44
45     void setApproach(float speed, float altitude);
46     void setApproach(float speed, float altitude, float aoa); 
47     void setCruise(float speed, float altitude);
48
49     void addApproachControl(int control, float val);
50     void addCruiseControl(int control, float val);
51
52     int numGear();
53     Gear* getGear(int g);
54     void setGearState(bool down, float dt);
55
56     int numTanks();
57     void setFuelFraction(float frac); // 0-1, total amount of fuel
58     float getFuel(int tank); // in kg!
59     float getFuelDensity(int tank); // kg/m^3
60
61     void compile(); // generate point masses & such, then solve
62     void stabilizeThrust();
63
64     // Solution output values
65     int getSolutionIterations();
66     float getDragCoefficient();
67     float getLiftRatio();
68     float getCruiseAoA();
69     float getTailIncidence();
70     char* getFailureMsg();
71
72 private:
73     struct Tank { float pos[3]; float cap; float fill;
74                   float density; int handle; };
75     struct Fuselage { float front[3], back[3], width, taper, mid; };
76     struct GearRec { Gear* gear; Surface* surf; float wgt; float time; };
77     struct ThrustRec { Thruster* thruster;
78                        int handle; float cg[3]; float mass; };
79     struct Control { int control; float val; };
80     struct WeightRec { int handle; Surface* surf; };
81
82     void runCruise();
83     void runApproach();
84     void setupState(float aoa, float speed, State* s);
85     void solveGear();
86     void solve();
87     float compileWing(Wing* w);
88     float compileFuselage(Fuselage* f);
89     void compileGear(GearRec* gr);
90     void applyDragFactor(float factor);
91     void applyLiftRatio(float factor);
92     float clamp(float val, float min, float max);
93     void addContactPoint(float* pos);
94     void compileContactPoints();
95     float normFactor(float f);
96
97     Model _model;
98     ControlMap _controls;
99
100     float _emptyWeight;
101     float _pilotPos[3];
102
103     Wing* _wing;
104     Wing* _tail;
105
106     Vector _fuselages;
107     Vector _vstabs;
108     Vector _tanks;
109     Vector _thrusters;
110     float _ballast;
111
112     Vector _gears;
113     Vector _contacts; // non-gear ground contact points
114     Vector _weights;
115     Vector _surfs; // NON-wing Surfaces
116
117     Vector _cruiseControls;
118     State _cruiseState;
119     float _cruiseP;
120     float _cruiseT;
121     float _cruiseSpeed;
122     float _cruiseWeight;
123
124     Vector _approachControls;
125     State _approachState;
126     float _approachP;
127     float _approachT;
128     float _approachSpeed;
129     float _approachAoA;
130     float _approachWeight;
131
132     int _solutionIterations;
133     float _dragFactor;
134     float _liftRatio;
135     float _cruiseAoA;
136     float _tailIncidence;
137     char* _failureMsg;
138 };
139
140 }; // namespace yasim
141 #endif // _AIRPLANE_HPP