4 #include "ControlMap.hpp"
20 void iterate(float dt);
21 void consumeFuel(float dt);
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);
62 void setFuelFraction(float frac); // 0-1, total amount of fuel
63 float getFuel(int tank); // in kg!
64 float getFuelDensity(int tank); // kg/m^3
65 float getTankCapacity(int tank);
67 void compile(); // generate point masses & such, then solve
69 void stabilizeThrust();
71 // Solution output values
72 int getSolutionIterations();
73 float getDragCoefficient();
76 float getTailIncidence();
77 float getApproachElevator() { return _approachElevator.val; }
78 char* getFailureMsg();
81 struct Tank { float pos[3]; float cap; float fill;
82 float density; int handle; };
83 struct Fuselage { float front[3], back[3], width, taper, mid; };
84 struct GearRec { Gear* gear; Surface* surf; float wgt; };
85 struct ThrustRec { Thruster* thruster;
86 int handle; float cg[3]; float mass; };
87 struct Control { int control; float val; };
88 struct WeightRec { int handle; Surface* surf; };
92 void setupState(float aoa, float speed, State* s);
95 void solveHelicopter();
96 float compileWing(Wing* w);
97 float compileRotor(Rotor* w);
98 float compileFuselage(Fuselage* f);
99 void compileGear(GearRec* gr);
100 void applyDragFactor(float factor);
101 void applyLiftRatio(float factor);
102 float clamp(float val, float min, float max);
103 void addContactPoint(float* pos);
104 void compileContactPoints();
105 float normFactor(float f);
106 void updateGearState();
109 ControlMap _controls;
124 Vector _contacts; // non-gear ground contact points
126 Vector _surfs; // NON-wing Surfaces
130 Vector _cruiseControls;
138 Vector _approachControls;
139 State _approachState;
142 float _approachSpeed;
144 float _approachWeight;
147 int _solutionIterations;
151 float _tailIncidence;
152 Control _approachElevator;
156 }; // namespace yasim
157 #endif // _AIRPLANE_HPP