4 #include "ControlMap.hpp"
20 void iterate(float dt);
21 void calcFuelWeights();
23 ControlMap* getControlMap();
26 void setPilotPos(float* pos);
27 void getPilotPos(float* out);
29 void getPilotAccel(float* out);
31 void setWeight(float weight);
33 void setWing(Wing* wing);
34 void setTail(Wing* tail);
35 void addVStab(Wing* vstab);
37 void addRotor(Rotor* Rotor);
38 int getNumRotors() {return _rotors.size();}
39 Rotor* getRotor(int i) {return (Rotor*)_rotors.get(i);}
41 void addFuselage(float* front, float* back, float width,
42 float taper=1, float mid=0.5);
43 int addTank(float* pos, float cap, float fuelDensity);
44 void addGear(Gear* g);
45 void addThruster(Thruster* t, float mass, float* cg);
46 void addBallast(float* pos, float mass);
48 int addWeight(float* pos, float size);
49 void setWeight(int handle, float mass);
51 void setApproach(float speed, float altitude, float aoa, float fuel);
52 void setCruise(float speed, float altitude, float fuel);
54 void setElevatorControl(int control);
55 void addApproachControl(int control, float val);
56 void addCruiseControl(int control, float val);
58 void addSolutionWeight(bool approach, int idx, float wgt);
63 int numThrusters() { return _thrusters.size(); }
64 Thruster* getThruster(int n) {
65 return ((ThrustRec*)_thrusters.get(n))->thruster; }
68 void setFuelFraction(float frac); // 0-1, total amount of fuel
69 float getFuel(int tank); // in kg!
70 float setFuel(int tank, float fuel); // in kg!
71 float getFuelDensity(int tank); // kg/m^3
72 float getTankCapacity(int tank);
74 void compile(); // generate point masses & such, then solve
76 void stabilizeThrust();
78 // Solution output values
79 int getSolutionIterations();
80 float getDragCoefficient();
83 float getTailIncidence();
84 float getApproachElevator() { return _approachElevator.val; }
85 char* getFailureMsg();
88 struct Tank { float pos[3]; float cap; float fill;
89 float density; int handle; };
90 struct Fuselage { float front[3], back[3], width, taper, mid; };
91 struct GearRec { Gear* gear; Surface* surf; float wgt; };
92 struct ThrustRec { Thruster* thruster;
93 int handle; float cg[3]; float mass; };
94 struct Control { int control; float val; };
95 struct WeightRec { int handle; Surface* surf; };
96 struct SolveWeight { bool approach; int idx; float wgt; };
100 void setupState(float aoa, float speed, State* s);
103 void solveHelicopter();
104 float compileWing(Wing* w);
105 float compileRotor(Rotor* w);
106 float compileFuselage(Fuselage* f);
107 void compileGear(GearRec* gr);
108 void applyDragFactor(float factor);
109 void applyLiftRatio(float factor);
110 float clamp(float val, float min, float max);
111 void addContactPoint(float* pos);
112 void compileContactPoints();
113 float normFactor(float f);
114 void updateGearState();
115 void setupWeights(bool isApproach);
118 ControlMap _controls;
133 Vector _contacts; // non-gear ground contact points
135 Vector _surfs; // NON-wing Surfaces
139 Vector _solveWeights;
141 Vector _cruiseControls;
149 Vector _approachControls;
150 State _approachState;
153 float _approachSpeed;
155 float _approachWeight;
158 int _solutionIterations;
162 float _tailIncidence;
163 Control _approachElevator;
167 }; // namespace yasim
168 #endif // _AIRPLANE_HPP