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);
58 void addSolutionWeight(bool approach, int idx, float wgt);
64 void setFuelFraction(float frac); // 0-1, total amount of fuel
65 float getFuel(int tank); // in kg!
66 float getFuelDensity(int tank); // kg/m^3
67 float getTankCapacity(int tank);
69 void compile(); // generate point masses & such, then solve
71 void stabilizeThrust();
73 // Solution output values
74 int getSolutionIterations();
75 float getDragCoefficient();
78 float getTailIncidence();
79 float getApproachElevator() { return _approachElevator.val; }
80 char* getFailureMsg();
83 struct Tank { float pos[3]; float cap; float fill;
84 float density; int handle; };
85 struct Fuselage { float front[3], back[3], width, taper, mid; };
86 struct GearRec { Gear* gear; Surface* surf; float wgt; };
87 struct ThrustRec { Thruster* thruster;
88 int handle; float cg[3]; float mass; };
89 struct Control { int control; float val; };
90 struct WeightRec { int handle; Surface* surf; };
91 struct SolveWeight { bool approach; int idx; float wgt; };
95 void setupState(float aoa, float speed, State* s);
98 void solveHelicopter();
99 float compileWing(Wing* w);
100 float compileRotor(Rotor* w);
101 float compileFuselage(Fuselage* f);
102 void compileGear(GearRec* gr);
103 void applyDragFactor(float factor);
104 void applyLiftRatio(float factor);
105 float clamp(float val, float min, float max);
106 void addContactPoint(float* pos);
107 void compileContactPoints();
108 float normFactor(float f);
109 void updateGearState();
110 void setupWeights(bool isApproach);
113 ControlMap _controls;
128 Vector _contacts; // non-gear ground contact points
130 Vector _surfs; // NON-wing Surfaces
134 Vector _solveWeights;
136 Vector _cruiseControls;
144 Vector _approachControls;
145 State _approachState;
148 float _approachSpeed;
150 float _approachWeight;
153 int _solutionIterations;
157 float _tailIncidence;
158 Control _approachElevator;
162 }; // namespace yasim
163 #endif // _AIRPLANE_HPP