4 #include "ControlMap.hpp"
23 void iterate(float dt);
24 void calcFuelWeights();
26 ControlMap* getControlMap();
29 void setPilotPos(float* pos);
30 void getPilotPos(float* out);
32 void getPilotAccel(float* out);
34 void setWeight(float weight);
36 void setWing(Wing* wing);
37 void setTail(Wing* tail);
38 void addVStab(Wing* vstab);
40 void addFuselage(float* front, float* back, float width,
41 float taper=1, float mid=0.5,
42 float cx=1, float cy=1, float cz=1, float idrag=1);
43 int addTank(float* pos, float cap, float fuelDensity);
44 void addGear(Gear* g);
45 void addHook(Hook* h);
46 void addLaunchbar(Launchbar* l);
47 void addThruster(Thruster* t, float mass, float* cg);
48 void addBallast(float* pos, float mass);
49 void addHitch(Hitch* h);
51 int addWeight(float* pos, float size);
52 void setWeight(int handle, float mass);
54 void setApproach(float speed, float altitude, float aoa, float fuel, float gla);
55 void setCruise(float speed, float altitude, float fuel, float gla);
57 void setElevatorControl(int control);
58 void addApproachControl(int control, float val);
59 void addCruiseControl(int control, float val);
61 void addSolutionWeight(bool approach, int idx, float wgt);
66 int numHitches() { return _hitches.size(); }
67 Hitch* getHitch(int h);
68 Rotorgear* getRotorgear();
69 Launchbar* getLaunchbar();
71 int numThrusters() { return _thrusters.size(); }
72 Thruster* getThruster(int n) {
73 return ((ThrustRec*)_thrusters.get(n))->thruster; }
76 void setFuelFraction(float frac); // 0-1, total amount of fuel
77 float getFuel(int tank); // in kg!
78 float setFuel(int tank, float fuel); // in kg!
79 float getFuelDensity(int tank); // kg/m^3
80 float getTankCapacity(int tank);
82 void compile(); // generate point masses & such, then solve
84 void stabilizeThrust();
86 // Solution output values
87 int getSolutionIterations();
88 float getDragCoefficient();
91 float getTailIncidence();
92 float getApproachElevator() { return _approachElevator.val; }
93 const char* getFailureMsg();
95 static void setupState(float aoa, float speed, float gla, State* s); // utility
98 struct Tank { float pos[3]; float cap; float fill;
99 float density; int handle; };
100 struct Fuselage { float front[3], back[3], width, taper, mid, _cx, _cy, _cz, _idrag; };
101 struct GearRec { Gear* gear; Surface* surf; float wgt; };
102 struct ThrustRec { Thruster* thruster;
103 int handle; float cg[3]; float mass; };
104 struct Control { int control; float val; };
105 struct WeightRec { int handle; Surface* surf; };
106 struct SolveWeight { bool approach; int idx; float wgt; };
107 struct ContactRec { Gear* gear; float p[3]; };
113 void solveHelicopter();
114 float compileWing(Wing* w);
115 void compileRotorgear();
116 float compileFuselage(Fuselage* f);
117 void compileGear(GearRec* gr);
118 void applyDragFactor(float factor);
119 void applyLiftRatio(float factor);
120 float clamp(float val, float min, float max);
121 void addContactPoint(float* pos);
122 void compileContactPoints();
123 float normFactor(float f);
124 void updateGearState();
125 void setupWeights(bool isApproach);
128 ControlMap _controls;
143 Vector _contacts; // non-gear ground contact points
145 Vector _surfs; // NON-wing Surfaces
146 Vector _hitches; //for airtow and winch
148 Vector _solveWeights;
150 Vector _cruiseControls;
157 float _cruiseGlideAngle;
159 Vector _approachControls;
160 State _approachState;
163 float _approachSpeed;
165 float _approachWeight;
167 float _approachGlideAngle;
169 int _solutionIterations;
173 float _tailIncidence;
174 Control _approachElevator;
175 const char* _failureMsg;
178 }; // namespace yasim
179 #endif // _AIRPLANE_HPP