2001-12-01 06:22:24 +00:00
|
|
|
#ifndef _AIRPLANE_HPP
|
|
|
|
#define _AIRPLANE_HPP
|
|
|
|
|
|
|
|
#include "ControlMap.hpp"
|
|
|
|
#include "Model.hpp"
|
|
|
|
#include "Wing.hpp"
|
2003-10-16 14:56:13 +00:00
|
|
|
#include "Rotor.hpp"
|
2001-12-06 18:16:22 +00:00
|
|
|
#include "Vector.hpp"
|
2001-12-01 06:22:24 +00:00
|
|
|
|
|
|
|
namespace yasim {
|
|
|
|
|
|
|
|
class Gear;
|
|
|
|
class Thruster;
|
|
|
|
|
|
|
|
class Airplane {
|
|
|
|
public:
|
|
|
|
Airplane();
|
|
|
|
~Airplane();
|
|
|
|
|
|
|
|
void iterate(float dt);
|
2002-11-30 20:22:25 +00:00
|
|
|
void consumeFuel(float dt);
|
2001-12-01 06:22:24 +00:00
|
|
|
|
|
|
|
ControlMap* getControlMap();
|
|
|
|
Model* getModel();
|
|
|
|
|
|
|
|
void setPilotPos(float* pos);
|
|
|
|
void getPilotPos(float* out);
|
|
|
|
|
|
|
|
void getPilotAccel(float* out);
|
|
|
|
|
|
|
|
void setWeight(float weight);
|
|
|
|
|
|
|
|
void setWing(Wing* wing);
|
|
|
|
void setTail(Wing* tail);
|
|
|
|
void addVStab(Wing* vstab);
|
|
|
|
|
2003-10-16 14:56:13 +00:00
|
|
|
void addRotor(Rotor* Rotor);
|
|
|
|
int getNumRotors() {return _rotors.size();}
|
|
|
|
Rotor* getRotor(int i) {return (Rotor*)_rotors.get(i);}
|
|
|
|
|
2001-12-24 13:54:03 +00:00
|
|
|
void addFuselage(float* front, float* back, float width,
|
|
|
|
float taper=1, float mid=0.5);
|
2001-12-01 06:22:24 +00:00
|
|
|
int addTank(float* pos, float cap, float fuelDensity);
|
2002-03-01 06:47:28 +00:00
|
|
|
void addGear(Gear* g);
|
2001-12-01 06:22:24 +00:00
|
|
|
void addThruster(Thruster* t, float mass, float* cg);
|
|
|
|
void addBallast(float* pos, float mass);
|
|
|
|
|
|
|
|
int addWeight(float* pos, float size);
|
|
|
|
void setWeight(int handle, float mass);
|
|
|
|
|
2004-02-17 23:24:36 +00:00
|
|
|
void setApproach(float speed, float altitude, float aoa, float fuel);
|
|
|
|
void setCruise(float speed, float altitude, float fuel);
|
2001-12-01 06:22:24 +00:00
|
|
|
|
2002-05-21 07:40:46 +00:00
|
|
|
void setElevatorControl(int control);
|
2001-12-01 06:22:24 +00:00
|
|
|
void addApproachControl(int control, float val);
|
|
|
|
void addCruiseControl(int control, float val);
|
|
|
|
|
2004-02-18 15:36:35 +00:00
|
|
|
void addSolutionWeight(bool approach, int idx, float wgt);
|
|
|
|
|
2001-12-01 06:22:24 +00:00
|
|
|
int numGear();
|
|
|
|
Gear* getGear(int g);
|
|
|
|
|
|
|
|
int numTanks();
|
|
|
|
void setFuelFraction(float frac); // 0-1, total amount of fuel
|
|
|
|
float getFuel(int tank); // in kg!
|
|
|
|
float getFuelDensity(int tank); // kg/m^3
|
2002-11-30 06:12:20 +00:00
|
|
|
float getTankCapacity(int tank);
|
2001-12-01 06:22:24 +00:00
|
|
|
|
|
|
|
void compile(); // generate point masses & such, then solve
|
2002-02-27 00:41:57 +00:00
|
|
|
void initEngines();
|
2001-12-24 13:54:03 +00:00
|
|
|
void stabilizeThrust();
|
2001-12-01 06:22:24 +00:00
|
|
|
|
|
|
|
// Solution output values
|
|
|
|
int getSolutionIterations();
|
|
|
|
float getDragCoefficient();
|
|
|
|
float getLiftRatio();
|
|
|
|
float getCruiseAoA();
|
|
|
|
float getTailIncidence();
|
2002-05-21 07:40:46 +00:00
|
|
|
float getApproachElevator() { return _approachElevator.val; }
|
2001-12-01 06:22:24 +00:00
|
|
|
char* getFailureMsg();
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Tank { float pos[3]; float cap; float fill;
|
|
|
|
float density; int handle; };
|
2001-12-24 13:54:03 +00:00
|
|
|
struct Fuselage { float front[3], back[3], width, taper, mid; };
|
2002-03-01 06:47:28 +00:00
|
|
|
struct GearRec { Gear* gear; Surface* surf; float wgt; };
|
2001-12-01 06:22:24 +00:00
|
|
|
struct ThrustRec { Thruster* thruster;
|
|
|
|
int handle; float cg[3]; float mass; };
|
|
|
|
struct Control { int control; float val; };
|
|
|
|
struct WeightRec { int handle; Surface* surf; };
|
2004-02-18 15:36:35 +00:00
|
|
|
struct SolveWeight { bool approach; int idx; float wgt; };
|
2001-12-01 06:22:24 +00:00
|
|
|
|
|
|
|
void runCruise();
|
|
|
|
void runApproach();
|
|
|
|
void setupState(float aoa, float speed, State* s);
|
|
|
|
void solveGear();
|
|
|
|
void solve();
|
2003-12-01 01:22:27 +00:00
|
|
|
void solveHelicopter();
|
2001-12-01 06:22:24 +00:00
|
|
|
float compileWing(Wing* w);
|
2003-10-16 14:56:13 +00:00
|
|
|
float compileRotor(Rotor* w);
|
2001-12-01 06:22:24 +00:00
|
|
|
float compileFuselage(Fuselage* f);
|
|
|
|
void compileGear(GearRec* gr);
|
|
|
|
void applyDragFactor(float factor);
|
|
|
|
void applyLiftRatio(float factor);
|
|
|
|
float clamp(float val, float min, float max);
|
2002-02-20 07:12:27 +00:00
|
|
|
void addContactPoint(float* pos);
|
|
|
|
void compileContactPoints();
|
2001-12-01 06:22:24 +00:00
|
|
|
float normFactor(float f);
|
2002-03-01 06:47:28 +00:00
|
|
|
void updateGearState();
|
2004-02-18 15:36:35 +00:00
|
|
|
void setupWeights(bool isApproach);
|
2001-12-01 06:22:24 +00:00
|
|
|
|
|
|
|
Model _model;
|
|
|
|
ControlMap _controls;
|
|
|
|
|
|
|
|
float _emptyWeight;
|
|
|
|
float _pilotPos[3];
|
|
|
|
|
|
|
|
Wing* _wing;
|
|
|
|
Wing* _tail;
|
|
|
|
|
|
|
|
Vector _fuselages;
|
|
|
|
Vector _vstabs;
|
|
|
|
Vector _tanks;
|
|
|
|
Vector _thrusters;
|
|
|
|
float _ballast;
|
|
|
|
|
|
|
|
Vector _gears;
|
2002-02-20 07:12:27 +00:00
|
|
|
Vector _contacts; // non-gear ground contact points
|
2001-12-01 06:22:24 +00:00
|
|
|
Vector _weights;
|
|
|
|
Vector _surfs; // NON-wing Surfaces
|
|
|
|
|
2003-10-16 14:56:13 +00:00
|
|
|
Vector _rotors;
|
|
|
|
|
2004-02-18 15:36:35 +00:00
|
|
|
Vector _solveWeights;
|
|
|
|
|
2001-12-01 06:22:24 +00:00
|
|
|
Vector _cruiseControls;
|
|
|
|
State _cruiseState;
|
2001-12-06 18:13:24 +00:00
|
|
|
float _cruiseP;
|
|
|
|
float _cruiseT;
|
2001-12-01 06:22:24 +00:00
|
|
|
float _cruiseSpeed;
|
|
|
|
float _cruiseWeight;
|
2004-02-17 23:24:36 +00:00
|
|
|
float _cruiseFuel;
|
2001-12-01 06:22:24 +00:00
|
|
|
|
|
|
|
Vector _approachControls;
|
|
|
|
State _approachState;
|
2001-12-06 18:13:24 +00:00
|
|
|
float _approachP;
|
|
|
|
float _approachT;
|
2001-12-01 06:22:24 +00:00
|
|
|
float _approachSpeed;
|
|
|
|
float _approachAoA;
|
|
|
|
float _approachWeight;
|
2004-02-17 23:24:36 +00:00
|
|
|
float _approachFuel;
|
2001-12-01 06:22:24 +00:00
|
|
|
|
|
|
|
int _solutionIterations;
|
|
|
|
float _dragFactor;
|
|
|
|
float _liftRatio;
|
|
|
|
float _cruiseAoA;
|
|
|
|
float _tailIncidence;
|
2002-05-21 07:40:46 +00:00
|
|
|
Control _approachElevator;
|
2001-12-01 06:22:24 +00:00
|
|
|
char* _failureMsg;
|
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace yasim
|
|
|
|
#endif // _AIRPLANE_HPP
|