1
0
Fork 0

YASim Wing: add _aspectRatio and _meanChord.

(an some indent)
This commit is contained in:
Henning Stahlke 2017-02-26 22:18:05 +01:00
parent a87442c6f3
commit cb7d2a1bc5
4 changed files with 56 additions and 43 deletions

View file

@ -440,7 +440,7 @@ int Airplane::getSolutionIterations()
return _solutionIterations;
}
void Airplane::setupState(float aoa, float speed, float gla, State* s)
void Airplane::setupState(const float aoa, const float speed, const float gla, State* s)
{
float cosAoA = Math::cos(aoa);
float sinAoA = Math::sin(aoa);
@ -494,8 +494,10 @@ float Airplane::compileWing(Wing* w)
_wingsN->getNode("base-x", true)->setFloatValue(tip[0]);
_wingsN->getNode("base-y", true)->setFloatValue(tip[1]);
_wingsN->getNode("base-z", true)->setFloatValue(tip[2]);
_wingsN->getNode("wingspan", true)->setFloatValue(w->getWingSpan());
_wingsN->getNode("wingarea", true)->setFloatValue(w->getWingArea());
_wingsN->getNode("wing-span", true)->setFloatValue(w->getSpan());
_wingsN->getNode("wing-area", true)->setFloatValue(w->getArea());
_wingsN->getNode("aspect-ratio", true)->setFloatValue(w->getAspectRatio());
_wingsN->getNode("mean-chord", true)->setFloatValue(w->getMAC());
}
float wgt = 0;
@ -772,7 +774,7 @@ void Airplane::compile()
if(_wing) {
float gepos[3];
float gespan = 0;
gespan = _wing->getWingSpan();
gespan = _wing->getSpan();
_wing->getBase(gepos);
// where does the hard coded factor 0.15 come from?
_model.setGroundEffect(gepos, gespan, 0.15f);

View file

@ -96,7 +96,7 @@ public:
float getApproachElevator() { return _approachElevator.val; }
const char* getFailureMsg();
static void setupState(float aoa, float speed, float gla, State* s); // utility
static void setupState(const float aoa, const float speed, const float gla, yasim::State* s); // utility
void loadApproachControls();
void loadCruiseControls();

View file

@ -2,6 +2,7 @@
#include "Wing.hpp"
namespace yasim {
static const float RAD2DEG = 57.2957795131;
Wing::Wing( Version * version ) :
_version(version)
@ -38,6 +39,9 @@ Wing::Wing( Version * version ) :
_slatEnd = 0;
_slatAoA = 0;
_slatDrag = 0;
_meanChord = 0;
_wingspan = 0;
_aspectRatio = 1;
}
Wing::~Wing()
@ -183,7 +187,6 @@ void Wing::setFlap0Effectiveness(float lval)
int i;
for(i=0; i<_flap0Surfs.size(); i++) {
((Surface*)_flap0Surfs.get(i))->setFlapEffectiveness(lval);
// if(_mirror) ((Surface*)_flap0Surfs.get(++i))->setFlapEffectiveness(rval);
}
}
@ -204,7 +207,6 @@ void Wing::setFlap1Effectiveness(float lval)
int i;
for(i=0; i<_flap1Surfs.size(); i++) {
((Surface*)_flap1Surfs.get(i))->setFlapEffectiveness(lval);
// if(_mirror) ((Surface*)_flap1Surfs.get(++i))->setFlap(rval);
}
}
@ -269,9 +271,6 @@ void Wing::compile()
last = bounds[i];
}
// Calculate a "nominal" segment length equal to an average chord,
// normalized to lie within 0-1 over the length of the wing.
float segLen = _chord * (0.5f*(_taper+1)) / _length;
// Generating a unit vector pointing out the left wing.
float left[3];
@ -286,7 +285,10 @@ void Wing::compile()
Math::set3(left, _tip);
Math::mul3(_length, _tip, _tip);
Math::add3(root, _tip, _tip);
_meanChord = _chord*(_taper+1)*0.5f;
// wingspan in y-direction (not for vstab)
_wingspan = Math::abs(2*_tip[1]);
_aspectRatio = _wingspan / _meanChord;
// The wing's Y axis will be the "left" vector. The Z axis will
// be perpendicular to this and the local (!) X axis, because we
@ -315,6 +317,10 @@ void Wing::compile()
for(i=3; i<6; i++) rightOrient[i] = -rightOrient[i];
}
// Calculate a "nominal" segment length equal to an average chord,
// normalized to lie within 0-1 over the length of the wing.
float segLen = _meanChord / _length;
// Now go through each boundary and make segments
for(i=0; i<(nbounds-1); i++) {
float start = bounds[i];

View file

@ -57,9 +57,12 @@ public:
void compile();
void getTip(float* tip) { Math::set3(_tip, tip);};
bool isMirrored() { return _mirror; };
// Used for ground effect
float getWingSpan() { return _wingspan; };
float getWingArea() {return 0.5f*_wingspan*_chord*(1+_taper); };
// valid only after Wing::compile() was called
float getSpan() { return _wingspan; };
float getArea() { return _wingspan*_meanChord; };
float getAspectRatio() { return _aspectRatio; };
float getMAC() { return _meanChord; };
// Query the list of Surface objects
int numSurfaces();
@ -100,7 +103,9 @@ private:
// calculated from above
float _tip[3];
float _meanChord;
float _wingspan;
float _aspectRatio;
float _stall;
float _stallWidth;