4 #include "ControlMap.hpp"
22 void iterate(float dt);
23 void calcFuelWeights();
25 ControlMap* getControlMap();
28 void setPilotPos(float* pos);
29 void getPilotPos(float* out);
31 void getPilotAccel(float* out);
33 void setWeight(float weight);
35 void setWing(Wing* wing);
36 void setTail(Wing* tail);
37 void addVStab(Wing* vstab);
39 void addRotor(Rotor* Rotor);
40 int getNumRotors() {return _rotors.size();}
41 Rotor* getRotor(int i) {return (Rotor*)_rotors.get(i);}
43 void addFuselage(float* front, float* back, float width,
44 float taper=1, float mid=0.5);
45 int addTank(float* pos, float cap, float fuelDensity);
46 void addGear(Gear* g);
47 void addHook(Hook* h);
48 void addLaunchbar(Launchbar* l);
49 void addThruster(Thruster* t, float mass, float* cg);
50 void addBallast(float* pos, float mass);
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);
56 void setCruise(float speed, float altitude, float fuel);
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 Launchbar* getLaunchbar();
69 int numThrusters() { return _thrusters.size(); }
70 Thruster* getThruster(int n) {
71 return ((ThrustRec*)_thrusters.get(n))->thruster; }
74 void setFuelFraction(float frac); // 0-1, total amount of fuel
75 float getFuel(int tank); // in kg!
76 float setFuel(int tank, float fuel); // in kg!
77 float getFuelDensity(int tank); // kg/m^3
78 float getTankCapacity(int tank);
80 void compile(); // generate point masses & such, then solve
82 void stabilizeThrust();
84 // Solution output values
85 int getSolutionIterations();
86 float getDragCoefficient();
89 float getTailIncidence();
90 float getApproachElevator() { return _approachElevator.val; }
91 char* getFailureMsg();
94 struct Tank { float pos[3]; float cap; float fill;
95 float density; int handle; };
96 struct Fuselage { float front[3], back[3], width, taper, mid; };
97 struct GearRec { Gear* gear; Surface* surf; float wgt; };
98 struct ThrustRec { Thruster* thruster;
99 int handle; float cg[3]; float mass; };
100 struct Control { int control; float val; };
101 struct WeightRec { int handle; Surface* surf; };
102 struct SolveWeight { bool approach; int idx; float wgt; };
106 void setupState(float aoa, float speed, State* s);
109 void solveHelicopter();
110 float compileWing(Wing* w);
111 float compileRotor(Rotor* w);
112 float compileFuselage(Fuselage* f);
113 void compileGear(GearRec* gr);
114 void applyDragFactor(float factor);
115 void applyLiftRatio(float factor);
116 float clamp(float val, float min, float max);
117 void addContactPoint(float* pos);
118 void compileContactPoints();
119 float normFactor(float f);
120 void updateGearState();
121 void setupWeights(bool isApproach);
124 ControlMap _controls;
139 Vector _contacts; // non-gear ground contact points
141 Vector _surfs; // NON-wing Surfaces
145 Vector _solveWeights;
147 Vector _cruiseControls;
155 Vector _approachControls;
156 State _approachState;
159 float _approachSpeed;
161 float _approachWeight;
164 int _solutionIterations;
168 float _tailIncidence;
169 Control _approachElevator;
173 }; // namespace yasim
174 #endif // _AIRPLANE_HPP