1
0
Fork 0

YASim declared get methods as const. (correction to previous commit)

This commit is contained in:
Henning Stahlke 2017-04-18 19:12:23 +02:00
parent 503907be34
commit 73de375249
9 changed files with 83 additions and 84 deletions

View file

@ -117,7 +117,7 @@ void Airplane::calcFuelWeights()
}
}
const void Airplane::getPilotAccel(float* out)
void Airplane::getPilotAccel(float* out)
{
State* s = _model.getState();
@ -1116,7 +1116,7 @@ void Airplane::solveHelicopter()
}
const float Airplane::getCGMAC()
float Airplane::getCGMAC()
{
float cg[3];
_model.getBody()->getCG(cg);

View file

@ -33,7 +33,7 @@ public:
void setPilotPos(float* pos) { Math::set3(pos, _pilotPos); }
void getPilotPos(float* out) { Math::set3(_pilotPos, out); }
const void getPilotAccel(float* out);
void getPilotAccel(float* out);
void setEmptyWeight(float weight) { _emptyWeight = weight; }
@ -65,52 +65,52 @@ public:
void addSolutionWeight(bool approach, int idx, float wgt);
const int numGear() { return _gears.size(); }
int numGear() const { return _gears.size(); }
Gear* getGear(int g) { return ((GearRec*)_gears.get(g))->gear; }
Hook* getHook() { return _model.getHook(); }
const int numHitches() { return _hitches.size(); }
Hook* getHook() const { return _model.getHook(); }
int numHitches() const { return _hitches.size(); }
Hitch* getHitch(int h);
Rotorgear* getRotorgear() { return _model.getRotorgear(); }
Launchbar* getLaunchbar() { return _model.getLaunchbar(); }
Launchbar* getLaunchbar() const { return _model.getLaunchbar(); }
const int numThrusters() { return _thrusters.size(); }
int numThrusters() const { return _thrusters.size(); }
Thruster* getThruster(int n) {
return ((ThrustRec*)_thrusters.get(n))->thruster; }
const int numTanks() { return _tanks.size(); }
int numTanks() const { return _tanks.size(); }
void setFuelFraction(float frac); // 0-1, total amount of fuel
// get fuel in kg
const float getFuel(int tank) { return ((Tank*)_tanks.get(tank))->fill; }
float getFuel(int tank) const { return ((Tank*)_tanks.get(tank))->fill; }
// set fuel in kg
float setFuel(int tank, float fuel) { return ((Tank*)_tanks.get(tank))->fill = fuel; }
// get fuel density in kg/m^3
const float getFuelDensity(int tank) { return ((Tank*)_tanks.get(tank))->density; }
const float getTankCapacity(int tank) { return ((Tank*)_tanks.get(tank))->cap; }
float getFuelDensity(int tank) const { return ((Tank*)_tanks.get(tank))->density; }
float getTankCapacity(int tank) const { return ((Tank*)_tanks.get(tank))->cap; }
void compile(); // generate point masses & such, then solve
void initEngines();
void stabilizeThrust();
// Solution output values
const int getSolutionIterations() { return _solutionIterations; }
const float getDragCoefficient() { return _dragFactor; }
const float getLiftRatio() { return _liftRatio; }
const float getCruiseAoA() { return _cruiseAoA; }
const float getTailIncidence() { return _tailIncidence; }
const float getApproachElevator() { return _approachElevator.val; }
const char* getFailureMsg() { return _failureMsg; }
int getSolutionIterations() const { return _solutionIterations; }
float getDragCoefficient() const { return _dragFactor; }
float getLiftRatio() const { return _liftRatio; }
float getCruiseAoA() const { return _cruiseAoA; }
float getTailIncidence() const { return _tailIncidence; }
float getApproachElevator() const { return _approachElevator.val; }
const char* getFailureMsg() const { return _failureMsg; }
static void setupState(const float aoa, const float speed, const float gla, yasim::State* s); // utility
void loadApproachControls() { loadControls(_approachControls); }
void loadCruiseControls() { loadControls(_cruiseControls); }
const float getCGHardLimitXMin() { return _cgMin; } // get min x-coordinate for c.g (from main gear)
const float getCGHardLimitXMax() { return _cgMax; } // get max x-coordinate for c.g (from nose gear)
const float getCGMAC(); // return c.g. x as fraction of MAC
float getCGHardLimitXMin() const { return _cgMin; } // get min x-coordinate for c.g (from main gear)
float getCGHardLimitXMax() const { return _cgMax; } // get max x-coordinate for c.g (from nose gear)
float getCGMAC(); // return c.g. x as fraction of MAC
// set desired range for C.G. in % of MAC, 0% = leading edge, 100% trailing edge
void setDesiredCGRangeInPercentOfMAC(float MACPercentMin, float MACPercentMax) { _cgDesiredMin = MACPercentMin; _cgDesiredMax = MACPercentMax; }
const float getCGSoftLimitXMin() { return _cgDesiredAft; } // get x-coordinate limit calculated from MAC and setCGRange values
const float getCGSoftLimitXMax() { return _cgDesiredFront; } // get x-coordinate limit calculated from MAC and setCGRange values
float getCGSoftLimitXMin() const { return _cgDesiredAft; } // get x-coordinate limit calculated from MAC and setCGRange values
float getCGSoftLimitXMax() const { return _cgDesiredFront; } // get x-coordinate limit calculated from MAC and setCGRange values
void setAutoBallast(bool allowed) { _autoBallast = allowed; }
private:

View file

@ -94,7 +94,7 @@ Model::~Model()
}
void Model::getThrust(float* out)
void Model::getThrust(float* out) const
{
float tmp[3];
out[0] = out[1] = out[2] = 0;
@ -196,21 +196,21 @@ void Model::setGroundCallback(Ground* ground_cb)
_ground_cb = ground_cb;
}
void Model::setGroundEffect(const float* pos, const float span, const float mul)
void Model::setGroundEffect(const float* pos, float span, float mul)
{
Math::set3(pos, _geRefPoint);
_wingSpan = span;
_groundEffect = mul;
}
void Model::setAir(const float pressure, const float temp, const float density)
void Model::setAir(float pressure, float temp, float density)
{
_pressure = pressure;
_temp = temp;
_rho = density;
}
void Model::setAirFromStandardAtmosphere(const float altitude)
void Model::setAirFromStandardAtmosphere(float altitude)
{
_pressure = Atmosphere::getStdPressure(altitude);
_temp = Atmosphere::getStdTemperature(altitude);

View file

@ -32,12 +32,12 @@ public:
void setTurbulence(Turbulence* turb) { _turb = turb; }
State* getState() { return _s; }
State* getState() const { return _s; }
void setState(State* s);
bool isCrashed() { return _crashed; }
bool isCrashed() const { return _crashed; }
void setCrashed(bool crashed) { _crashed = crashed; }
float getAGL() { return _agl; }
float getAGL() const { return _agl; }
void iterate();
@ -47,19 +47,18 @@ public:
int addGear(Gear* gear) { return _gears.add(gear); }
void addHook(Hook* hook) { _hook = hook; }
void addLaunchbar(Launchbar* launchbar) { _launchbar = launchbar; }
Surface* getSurface(int handle) { return (Surface*)_surfaces.get(handle); }
Surface* getSurface(int handle) const { return (Surface*)_surfaces.get(handle); }
Rotorgear* getRotorgear(void) { return &_rotorgear; }
Gear* getGear(int handle);
Hook* getHook(void) { return _hook; }
Hook* getHook(void) const { return _hook; }
int addHitch(Hitch* hitch) { return _hitches.add(hitch); }
Launchbar* getLaunchbar(void) { return _launchbar; }
Launchbar* getLaunchbar(void) const { return _launchbar; }
// Semi-private methods for use by the Airplane solver.
int numThrusters() { return _thrusters.size(); }
int numThrusters() const { return _thrusters.size(); }
Thruster* getThruster(int handle) { return (Thruster*)_thrusters.get(handle); }
void setThruster(int handle, Thruster* t) { _thrusters.set(handle, t); }
void initIteration();
void getThrust(float* out);
void getThrust(float* out) const;
void setGroundCallback(Ground* ground_cb);
Ground* getGroundCallback(void) { return _ground_cb; }
@ -67,10 +66,10 @@ public:
//
// Per-iteration settables
//
void setGroundEffect(const float* pos, const float span, const float mul);
void setGroundEffect(const float* pos, float span, float mul);
void setWind(float* wind) { Math::set3(wind, _wind); }
void setAir(const float pressure, const float temp, const float density);
void setAirFromStandardAtmosphere(const float altitude);
void setAir(float pressure, float temp, float density);
void setAirFromStandardAtmosphere(float altitude);
void updateGround(State* s);

View file

@ -67,7 +67,7 @@ void RigidBody::setMass(int handle, float mass, const float* pos, bool isStatic)
}
}
void RigidBody::getMassPosition(int handle, float* out)
void RigidBody::getMassPosition(int handle, float* out) const
{
out[0] = _masses[handle].p[0];
out[1] = _masses[handle].p[1];
@ -217,7 +217,7 @@ void RigidBody::addForce(const float* pos, const float* force)
addTorque(t);
}
void RigidBody::getAccel(float* pos, float* accelOut)
void RigidBody::getAccel(float* pos, float* accelOut) const
{
getAccel(accelOut);
@ -241,7 +241,7 @@ void RigidBody::getAccel(float* pos, float* accelOut)
Math::add3(v, accelOut, accelOut);
}
void RigidBody::getAngularAccel(float* accelOut)
void RigidBody::getAngularAccel(float* accelOut) const
{
// Compute "tau" as the externally applied torque, plus the
// counter-torque due to the internal gyro.
@ -258,7 +258,7 @@ void RigidBody::getAngularAccel(float* accelOut)
Math::vmul33(_invI, v, v); // v = invI*(tau + (omega X I*omega))
}
void RigidBody::getInertiaMatrix(float* inertiaOut)
void RigidBody::getInertiaMatrix(float* inertiaOut) const
{
// valid only after a call to RigidBody::recalc()
// See comment at top of RigidBody.hpp on units.

View file

@ -37,10 +37,10 @@ public:
void setMass(int handle, float mass);
void setMass(int handle, float mass, const float* pos, bool isStatic = false);
int numMasses() { return _nMasses; }
float getMass(int handle) { return _masses[handle].m; }
void getMassPosition(int handle, float* out);
float getTotalMass() { return _totalMass; }
int numMasses() const { return _nMasses; }
float getMass(int handle) const { return _masses[handle].m; }
void getMassPosition(int handle, float* out) const;
float getTotalMass() const { return _totalMass; }
// The velocity, in local coordinates, of the specified point on a
// body rotating about its c.g. with velocity rot.
@ -83,24 +83,24 @@ public:
// Returns the center of gravity of the masses, in the body
// coordinate system. valid only after recalc()
void getCG(float* cgOut) { Math::set3(_cg, cgOut); }
void getCG(float* cgOut) const { Math::set3(_cg, cgOut); }
// Returns the acceleration of the body's c.g. relative to the
// rest of the world, specified in local coordinates.
void getAccel(float* accelOut) { Math::mul3(1/_totalMass, _force, accelOut); }
void getAccel(float* accelOut) const { Math::mul3(1/_totalMass, _force, accelOut); }
// Returns the acceleration of a specific location in local
// coordinates. If the body is rotating, this will be different
// from the c.g. acceleration due to the centripetal accelerations
// of points not on the rotation axis.
void getAccel(float* pos, float* accelOut);
void getAccel(float* pos, float* accelOut) const;
// Returns the instantaneous rate of change of the angular
// velocity, as a vector in local coordinates.
void getAngularAccel(float* accelOut);
void getAngularAccel(float* accelOut) const;
// Returns the intertia tensor in a float[9] allocated by caller.
void getInertiaMatrix(float* inertiaOut);
void getInertiaMatrix(float* inertiaOut) const;
private:
/**

View file

@ -18,12 +18,12 @@ class Surface
public:
Surface( Version * version );
int getID() { return _id; };
int getID() const { return _id; };
static void resetIDgen() { s_idGenerator = 0; };
// Position of this surface in local coords
void setPosition(const float* p);
void getPosition(float* out) { Math::set3(_pos, out); }
void getPosition(float* out) const { Math::set3(_pos, out); }
// Distance scale along the X axis
void setChord(float chord) { _chord = chord; }
@ -46,7 +46,7 @@ public:
// Modifier for flap lift coefficient, useful for simulating flap blowing etc.
void setFlapEffectiveness(float effectiveness) { _flapEffectiveness = effectiveness; }
double getFlapEffectiveness() { return _flapEffectiveness; }
double getFlapEffectiveness() const { return _flapEffectiveness; }
// local -> Surface coords
void setOrientation(const float* o);
@ -60,12 +60,12 @@ public:
void setTwist(float angle) { _twist = angle; }
void setTotalDrag(float c0) { _c0 = c0; }
float getTotalDrag() { return _c0; }
float getTotalDrag() const { return _c0; }
void setXDrag(float cx) { _cx = cx; }
void setYDrag(float cy) { _cy = cy; }
void setZDrag(float cz) { _cz = cz; }
float getXDrag() { return _cx; }
float getXDrag() const { return _cx; }
// zero-alpha Z drag ("camber") specified as a fraction of cz
void setBaseZDrag(float cz0) { _cz0 = cz0; }
@ -82,8 +82,8 @@ public:
void calcForce(const float* v, const float rho, float* out, float* torque);
float getAlpha() { return _alpha; };
float getStallAlpha() { return _stallAlpha; };
float getAlpha() const { return _alpha; };
float getStallAlpha() const { return _stallAlpha; };
private:
SGPropertyNode_ptr _surfN;

View file

@ -12,10 +12,10 @@ public:
Vector();
~Vector();
int add(void* p);
void* get(int i);
void* get(int i) const;
void set(int i, void* p);
int size();
bool empty();
int size() const;
bool empty() const;
private:
void realloc();
@ -44,7 +44,7 @@ inline int Vector::add(void* p)
return _sz++;
}
inline void* Vector::get(int i)
inline void* Vector::get(int i) const
{
return _array[i];
}
@ -54,12 +54,12 @@ inline void Vector::set(int i, void* p)
_array[i] = p;
}
inline int Vector::size()
inline int Vector::size() const
{
return _sz;
}
inline bool Vector::empty()
inline bool Vector::empty() const
{
return _sz == 0;
}

View file

@ -23,22 +23,22 @@ public:
// base point of wing
void setBase(const float* base) { Math::set3(base, _base); }
const void getBase(float* base) { Math::set3(_base, base); };
void getBase(float* base) const { Math::set3(_base, base); };
// dist. ALONG wing (not span!)
void setLength(float length) { _length = length; }
const float getLength() { return _length; };
float getLength() const { return _length; };
// at base, measured along X axis
void setChord(float chord) { _chord = chord; }
const float getChord() { return _chord; };
float getChord() const { return _chord; };
// fraction of chord at wing tip, 0..1
void setTaper(float taper) { _taper = taper; }
const float getTaper() { return _taper; };
float getTaper() const { return _taper; };
// radians
void setSweep(float sweep) { _sweep = sweep; }
const float getSweep() { return _sweep; };
float getSweep() const { return _sweep; };
// radians, positive is "up"
void setDihedral(float dihedral) { _dihedral = dihedral; }
const float getDihedral() { return _dihedral; };
float getDihedral() const { return _dihedral; };
void setIncidence(float incidence);
void setTwist(float angle) { _twist = angle; }
@ -67,31 +67,31 @@ public:
// Compile the thing into a bunch of Surface objects
void compile();
const void getTip(float* tip) { Math::set3(_tip, tip);};
void getTip(float* tip) const { Math::set3(_tip, tip);};
// valid only after Wing::compile() was called
const float getSpan() { return _wingspan; };
const float getArea() { return _wingspan*_meanChord; };
const float getAspectRatio() { return _aspectRatio; };
const float getSMC() { return _meanChord; };
const float getMAC() { return _mac; }; // get length of MAC
const float getMACx() { return _macX; }; // get x-coord of MAC leading edge
const float getMACy() { return _base[1]+_macRootDistance; }; // get y-coord of MAC leading edge
float getSpan() const { return _wingspan; };
float getArea() const { return _wingspan*_meanChord; };
float getAspectRatio() const { return _aspectRatio; };
float getSMC() const { return _meanChord; };
float getMAC() const { return _mac; }; // get length of MAC
float getMACx() const { return _macX; }; // get x-coord of MAC leading edge
float getMACy() const { return _base[1]+_macRootDistance; }; // get y-coord of MAC leading edge
const int numSurfaces() { return _surfs.size(); }
int numSurfaces() const { return _surfs.size(); }
Surface* getSurface(int n) { return ((SurfRec*)_surfs.get(n))->surface; }
const float getSurfaceWeight(int n) { return ((SurfRec*)_surfs.get(n))->weight; }
float getSurfaceWeight(int n) const { return ((SurfRec*)_surfs.get(n))->weight; }
// The overall drag coefficient for the wing as a whole. Units are
// arbitrary.
void setDragScale(float scale);
const float getDragScale() { return _dragScale; }
float getDragScale() const { return _dragScale; }
// The ratio of force along the Z (lift) direction of each wing
// segment to that along the X (drag) direction.
void setLiftRatio(float ratio);
const float getLiftRatio() { return _liftRatio; }
float getLiftRatio() const { return _liftRatio; }
private:
void interp(const float* v1, const float* v2, const float frac, float* out);