1
0
Fork 0

YASim: changed constructor for Wing. Creating a Wing object without basic geometry data is pointless and this data cannot change during runtime.

This commit is contained in:
Henning Stahlke 2017-05-04 14:31:43 +02:00
parent 614f05bb39
commit 6817292e73
3 changed files with 47 additions and 45 deletions

View file

@ -800,37 +800,40 @@ void FGFDM::setOutputProperties(float dt)
Wing* FGFDM::parseWing(XMLAttributes* a, const char* type, Version * version)
{
Wing* w = new Wing(version);
float defDihed = 0;
if(eq(type, "vstab"))
defDihed = 90;
else
w->setMirror(true);
bool mirror = true;
float pos[3];
pos[0] = attrf(a, "x");
pos[1] = attrf(a, "y");
pos[2] = attrf(a, "z");
w->setBase(pos);
w->setLength(attrf(a, "length"));
w->setChord(attrf(a, "chord"));
w->setSweep(attrf(a, "sweep", 0) * DEG2RAD);
w->setTaper(attrf(a, "taper", 1));
w->setDihedral(attrf(a, "dihedral", defDihed) * DEG2RAD);
float camber = attrf(a, "camber", 0);
if (!version->isVersionOrNewer(Version::YASIM_VERSION_2017_2) && (camber == 0)) {
SG_LOG(SG_FLIGHT, SG_DEV_WARN, "YASIM warning: versions before 2017.2 are buggy for wings with camber=0");
if(eq(type, "vstab")) {
defDihed = 90;
mirror = false;
}
w->setCamber(camber);
float base[3];
base[0] = attrf(a, "x");
base[1] = attrf(a, "y");
base[2] = attrf(a, "z");
float length = attrf(a, "length");
float chord = attrf(a, "chord");
float sweep = attrf(a, "sweep", 0) * DEG2RAD;
float taper = attrf(a, "taper", 1);
float dihedral = attrf(a, "dihedral", defDihed) * DEG2RAD;
// These come in with positive indicating positive AoA, but the
// internals expect a rotation about the left-pointing Y axis, so
// invert the sign.
w->setIncidence(attrf(a, "incidence", 0) * DEG2RAD * -1);
w->setTwist(attrf(a, "twist", 0) * DEG2RAD * -1);
float incidence = attrf(a, "incidence", 0) * DEG2RAD * -1;
float twist = attrf(a, "twist", 0) * DEG2RAD * -1;
float camber = attrf(a, "camber", 0);
if (!version->isVersionOrNewer(Version::YASIM_VERSION_2017_2) && (camber == 0)) {
SG_LOG(SG_FLIGHT, SG_DEV_WARN, "YASIM warning: versions before 2017.2 are buggy for wings with camber=0");
}
Wing* w = new Wing(version, mirror, base, chord, length,
taper, sweep, dihedral, twist);
w->setIncidence(incidence);
w->setCamber(camber);
// The 70% is a magic number that sorta kinda seems to match known
// throttle settings to approach speed.

View file

@ -4,10 +4,23 @@
namespace yasim {
Wing::Wing( Version * version ) :
_version(version)
Wing::Wing(Version *ver, bool mirror, float* base, float chord,
float length, float taper, float sweep, float dihedral, float twist) :
_version(ver),
_mirror(mirror),
_chord(chord),
_length(length),
_taper(taper),
_sweep(sweep),
_dihedral(dihedral),
_twist(twist)
{
Math::set3(base, _base);
_meanChord = _chord*(_taper+1)*0.5f;
calculateWingCoordinateSystem();
calculateTip();
calculateSpan();
calculateMAC();
}
Wing::~Wing()
@ -207,13 +220,6 @@ void Wing::compile()
last = bounds[i];
}
calculateWingCoordinateSystem();
calculateTip();
_meanChord = _chord*(_taper+1)*0.5f;
calculateSpan();
calculateMAC();
// 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;

View file

@ -12,7 +12,8 @@ class Surface;
// FIXME: need to handle "inverted" controls for mirrored wings.
class Wing {
public:
Wing( Version * version );
Wing(Version *ver, bool mirror, float* base, float chord, float length,
float taper = 1, float sweep = 0, float dihedral = 0, float twist = 0);
~Wing();
// Do we mirror ourselves about the XZ plane?
@ -22,26 +23,20 @@ public:
// Wing geometry in local coordinates:
// base point of wing
void setBase(const 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; }
float getLength() const { return _length; };
// at base, measured along X axis
void setChord(float chord) { _chord = chord; }
float getChord() const { return _chord; };
// fraction of chord at wing tip, 0..1
void setTaper(float taper) { _taper = taper; }
float getTaper() const { return _taper; };
// radians
void setSweep(float sweep) { _sweep = sweep; }
float getSweep() const { return _sweep; };
// radians, positive is "up"
void setDihedral(float dihedral) { _dihedral = dihedral; }
float getDihedral() const { return _dihedral; };
void setIncidence(float incidence);
void setTwist(float angle) { _twist = angle; }
// parameters for stall curve
@ -110,11 +105,11 @@ private:
Vector _slatSurfs;
Vector _spoilerSurfs;
Version * _version;
bool _mirror {false};
float _base[3] {0,0,0};
float _length {0};
float _chord {0};
float _length {0};
float _taper {1};
float _sweep {0};
float _dihedral {0};
@ -161,8 +156,6 @@ private:
float _slatEnd {0};
float _slatAoA {0};
float _slatDrag {0};
Version * _version;
};
}; // namespace yasim