4 #include "ControlMap.hpp"
19 class Airplane : public Version {
24 void iterate(float dt);
25 void calcFuelWeights();
27 ControlMap* getControlMap();
30 void setPilotPos(float* pos);
31 void getPilotPos(float* out);
33 void getPilotAccel(float* out);
35 void setWeight(float weight);
37 void setWing(Wing* wing);
38 void setTail(Wing* tail);
39 void addVStab(Wing* vstab);
41 void addFuselage(float* front, float* back, float width,
42 float taper=1, float mid=0.5,
43 float cx=1, float cy=1, float cz=1, float idrag=1);
44 int addTank(float* pos, float cap, float fuelDensity);
45 void addGear(Gear* g);
46 void addHook(Hook* h);
47 void addLaunchbar(Launchbar* l);
48 void addThruster(Thruster* t, float mass, float* cg);
49 void addBallast(float* pos, float mass);
50 void addHitch(Hitch* h);
52 int addWeight(float* pos, float size);
53 void setWeight(int handle, float mass);
55 void setApproach(float speed, float altitude, float aoa, float fuel, float gla);
56 void setCruise(float speed, float altitude, float fuel, float gla);
58 void setElevatorControl(int control);
59 void addApproachControl(int control, float val);
60 void addCruiseControl(int control, float val);
62 void addSolutionWeight(bool approach, int idx, float wgt);
67 int numHitches() { return _hitches.size(); }
68 Hitch* getHitch(int h);
69 Rotorgear* getRotorgear();
70 Launchbar* getLaunchbar();
72 int numThrusters() { return _thrusters.size(); }
73 Thruster* getThruster(int n) {
74 return ((ThrustRec*)_thrusters.get(n))->thruster; }
77 void setFuelFraction(float frac); // 0-1, total amount of fuel
78 float getFuel(int tank); // in kg!
79 float setFuel(int tank, float fuel); // in kg!
80 float getFuelDensity(int tank); // kg/m^3
81 float getTankCapacity(int tank);
83 void compile(); // generate point masses & such, then solve
85 void stabilizeThrust();
87 // Solution output values
88 int getSolutionIterations();
89 float getDragCoefficient();
92 float getTailIncidence();
93 float getApproachElevator() { return _approachElevator.val; }
94 const char* getFailureMsg();
96 static void setupState(float aoa, float speed, float gla, State* s); // utility
99 struct Tank { float pos[3]; float cap; float fill;
100 float density; int handle; };
101 struct Fuselage { float front[3], back[3], width, taper, mid, _cx, _cy, _cz, _idrag;
103 struct GearRec { Gear* gear; Surface* surf; float wgt; };
104 struct ThrustRec { Thruster* thruster;
105 int handle; float cg[3]; float mass; };
106 struct Control { int control; float val; };
107 struct WeightRec { int handle; Surface* surf; };
108 struct SolveWeight { bool approach; int idx; float wgt; };
109 struct ContactRec { Gear* gear; float p[3]; };
115 void solveHelicopter();
116 float compileWing(Wing* w);
117 void compileRotorgear();
118 float compileFuselage(Fuselage* f);
119 void compileGear(GearRec* gr);
120 void applyDragFactor(float factor);
121 void applyLiftRatio(float factor);
122 float clamp(float val, float min, float max);
123 void addContactPoint(float* pos);
124 void compileContactPoints();
125 float normFactor(float f);
126 void updateGearState();
127 void setupWeights(bool isApproach);
130 ControlMap _controls;
145 Vector _contacts; // non-gear ground contact points
147 Vector _surfs; // NON-wing Surfaces
148 Vector _hitches; //for airtow and winch
150 Vector _solveWeights;
152 Vector _cruiseControls;
159 float _cruiseGlideAngle;
161 Vector _approachControls;
162 State _approachState;
165 float _approachSpeed;
167 float _approachWeight;
169 float _approachGlideAngle;
171 int _solutionIterations;
175 float _tailIncidence;
176 Control _approachElevator;
177 const char* _failureMsg;
180 }; // namespace yasim
181 #endif // _AIRPLANE_HPP