YASim: split Wing::compile into smaller functions (1).
This commit is contained in:
parent
eb6bb087f6
commit
4584c83d8b
2 changed files with 23 additions and 11 deletions
|
@ -111,6 +111,23 @@ void Wing::setSlatPos(float 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()
|
||||
{
|
||||
// Have we already been compiled?
|
||||
|
@ -167,16 +184,9 @@ void Wing::compile()
|
|||
Math::mul3(_length, left, _tip);
|
||||
Math::add3(_base, _tip, _tip);
|
||||
_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]));
|
||||
// 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;
|
||||
|
||||
calculateSpan();
|
||||
calculateMAC();
|
||||
|
||||
// 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
|
||||
|
|
|
@ -97,7 +97,9 @@ private:
|
|||
void interp(const float* v1, const float* v2, const float frac, float* out);
|
||||
Surface* newSurface(float* pos, float* orient, float chord,
|
||||
bool hasFlap0, bool hasFlap1, bool hasSlat, bool hasSpoiler);
|
||||
|
||||
void calculateSpan();
|
||||
void calculateMAC();
|
||||
|
||||
struct SurfRec { Surface * surface; float weight; };
|
||||
|
||||
Vector _surfs;
|
||||
|
|
Loading…
Reference in a new issue