4 #include "ControlMap.hpp"
19 void iterate(float dt);
21 ControlMap* getControlMap();
24 void setPilotPos(float* pos);
25 void getPilotPos(float* out);
27 void getPilotAccel(float* out);
29 void setWeight(float weight);
31 void setWing(Wing* wing);
32 void setTail(Wing* tail);
33 void addVStab(Wing* vstab);
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);
39 void addThruster(Thruster* t, float mass, float* cg);
40 void addBallast(float* pos, float mass);
42 int addWeight(float* pos, float size);
43 void setWeight(int handle, float mass);
45 void setApproach(float speed, float altitude);
46 void setApproach(float speed, float altitude, float aoa);
47 void setCruise(float speed, float altitude);
49 void setElevatorControl(int control);
50 void addApproachControl(int control, float val);
51 void addCruiseControl(int control, float val);
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
61 void compile(); // generate point masses & such, then solve
63 void stabilizeThrust();
65 // Solution output values
66 int getSolutionIterations();
67 float getDragCoefficient();
70 float getTailIncidence();
71 float getApproachElevator() { return _approachElevator.val; }
72 char* getFailureMsg();
75 struct Tank { float pos[3]; float cap; float fill;
76 float density; int handle; };
77 struct Fuselage { float front[3], back[3], width, taper, mid; };
78 struct GearRec { Gear* gear; Surface* surf; float wgt; };
79 struct ThrustRec { Thruster* thruster;
80 int handle; float cg[3]; float mass; };
81 struct Control { int control; float val; };
82 struct WeightRec { int handle; Surface* surf; };
86 void setupState(float aoa, float speed, State* s);
89 float compileWing(Wing* w);
90 float compileFuselage(Fuselage* f);
91 void compileGear(GearRec* gr);
92 void applyDragFactor(float factor);
93 void applyLiftRatio(float factor);
94 float clamp(float val, float min, float max);
95 void addContactPoint(float* pos);
96 void compileContactPoints();
97 float normFactor(float f);
98 void updateGearState();
101 ControlMap _controls;
116 Vector _contacts; // non-gear ground contact points
118 Vector _surfs; // NON-wing Surfaces
120 Vector _cruiseControls;
127 Vector _approachControls;
128 State _approachState;
131 float _approachSpeed;
133 float _approachWeight;
135 int _solutionIterations;
139 float _tailIncidence;
140 Control _approachElevator;
144 }; // namespace yasim
145 #endif // _AIRPLANE_HPP