1
0
Fork 0

YASim: split Wing::compile into smaller functions (1).

This commit is contained in:
Henning Stahlke 2017-05-04 14:02:11 +02:00
parent eb6bb087f6
commit 4584c83d8b
2 changed files with 23 additions and 11 deletions

View file

@ -111,6 +111,23 @@ void Wing::setSlatPos(float val)
((Surface*)_slatSurfs.get(i))->setSlatPos(val); ((Surface*)_slatSurfs.get(i))->setSlatPos(val);
} }
void Wing::calculateSpan()
{
// wingspan in y-direction (not for vstab)
_wingspan = Math::abs(2*_tip[1]);
_netSpan = Math::abs(2*(_tip[1]-_base[1]));
_aspectRatio = _wingspan / _meanChord;
}
void Wing::calculateMAC()
{
// http://www.nasascale.org/p2/wp-content/uploads/mac-calculator.htm
const float commonFactor = _chord*(0.5+_taper)/(3*_chord*(1+_taper));
_mac = _chord-(2*_chord*(1-_taper)*commonFactor);
_macRootDistance = _netSpan*commonFactor;
_macX = _base[0]-Math::tan(_sweep) * _macRootDistance + _mac/2;
}
void Wing::compile() void Wing::compile()
{ {
// Have we already been compiled? // Have we already been compiled?
@ -167,16 +184,9 @@ void Wing::compile()
Math::mul3(_length, left, _tip); Math::mul3(_length, left, _tip);
Math::add3(_base, _tip, _tip); Math::add3(_base, _tip, _tip);
_meanChord = _chord*(_taper+1)*0.5f; _meanChord = _chord*(_taper+1)*0.5f;
// wingspan in y-direction (not for vstab)
_wingspan = Math::abs(2*_tip[1]);
_aspectRatio = _wingspan / _meanChord;
_netSpan = Math::abs(2*(_tip[1]-_base[1])); calculateSpan();
// http://www.nasascale.org/p2/wp-content/uploads/mac-calculator.htm calculateMAC();
const float commonFactor = _chord*(0.5+_taper)/(3*_chord*(1+_taper));
_mac = _chord-(2*_chord*(1-_taper)*commonFactor);
_macRootDistance = _netSpan*commonFactor;
_macX = _base[0]-Math::tan(_sweep) * _macRootDistance + _mac/2;
// The wing's Y axis will be the "left" vector. The Z axis will // 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 // be perpendicular to this and the local (!) X axis, because we

View file

@ -97,6 +97,8 @@ private:
void interp(const float* v1, const float* v2, const float frac, float* out); void interp(const float* v1, const float* v2, const float frac, float* out);
Surface* newSurface(float* pos, float* orient, float chord, Surface* newSurface(float* pos, float* orient, float chord,
bool hasFlap0, bool hasFlap1, bool hasSlat, bool hasSpoiler); bool hasFlap0, bool hasFlap1, bool hasSlat, bool hasSpoiler);
void calculateSpan();
void calculateMAC();
struct SurfRec { Surface * surface; float weight; }; struct SurfRec { Surface * surface; float weight; };