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 addFuselage(float* front, float* back, float width,
40 float taper=1, float mid=0.5);
41 int addTank(float* pos, float cap, float fuelDensity);
42 void addGear(Gear* g);
43 void addHook(Hook* h);
44 void addLaunchbar(Launchbar* l);
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 Rotorgear* getRotorgear();
64 Launchbar* getLaunchbar();
66 int numThrusters() { return _thrusters.size(); }
67 Thruster* getThruster(int n) {
68 return ((ThrustRec*)_thrusters.get(n))->thruster; }
71 void setFuelFraction(float frac); // 0-1, total amount of fuel
72 float getFuel(int tank); // in kg!
73 float setFuel(int tank, float fuel); // in kg!
74 float getFuelDensity(int tank); // kg/m^3
75 float getTankCapacity(int tank);
77 void compile(); // generate point masses & such, then solve
79 void stabilizeThrust();
81 // Solution output values
82 int getSolutionIterations();
83 float getDragCoefficient();
86 float getTailIncidence();
87 float getApproachElevator() { return _approachElevator.val; }
88 char* getFailureMsg();
90 static void setupState(float aoa, float speed, State* s); // utility
93 struct Tank { float pos[3]; float cap; float fill;
94 float density; int handle; };
95 struct Fuselage { float front[3], back[3], width, taper, mid; };
96 struct GearRec { Gear* gear; Surface* surf; float wgt; };
97 struct ThrustRec { Thruster* thruster;
98 int handle; float cg[3]; float mass; };
99 struct Control { int control; float val; };
100 struct WeightRec { int handle; Surface* surf; };
101 struct SolveWeight { bool approach; int idx; float wgt; };
102 struct ContactRec { Gear* gear; float p[3]; };
108 void solveHelicopter();
109 float compileWing(Wing* w);
110 float compileRotorgear();
111 float compileFuselage(Fuselage* f);
112 void compileGear(GearRec* gr);
113 void applyDragFactor(float factor);
114 void applyLiftRatio(float factor);
115 float clamp(float val, float min, float max);
116 void addContactPoint(float* pos);
117 void compileContactPoints();
118 float normFactor(float f);
119 void updateGearState();
120 void setupWeights(bool isApproach);
123 ControlMap _controls;
138 Vector _contacts; // non-gear ground contact points
140 Vector _surfs; // NON-wing Surfaces
142 Vector _solveWeights;
144 Vector _cruiseControls;
152 Vector _approachControls;
153 State _approachState;
156 float _approachSpeed;
158 float _approachWeight;
161 int _solutionIterations;
165 float _tailIncidence;
166 Control _approachElevator;
170 }; // namespace yasim
171 #endif // _AIRPLANE_HPP