From 7228024ed586ca122c5aede318ee4b57ea17b5b2 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 18 Feb 2003 16:50:07 +0000 Subject: [PATCH] Added a "twist" attribute for wings to allow for washout (or washin, if desired) in the stall. This allows for fairly docile stalls when desired, as on trainers (you also need to limit the elevator lift). --- src/FDM/YASim/FGFDM.cpp | 1 + src/FDM/YASim/Surface.cpp | 11 +++++++++-- src/FDM/YASim/Surface.hpp | 4 ++++ src/FDM/YASim/Wing.cpp | 10 ++++++++++ src/FDM/YASim/Wing.hpp | 2 ++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/FDM/YASim/FGFDM.cpp b/src/FDM/YASim/FGFDM.cpp index 81b50bfb6..e959df3c7 100644 --- a/src/FDM/YASim/FGFDM.cpp +++ b/src/FDM/YASim/FGFDM.cpp @@ -415,6 +415,7 @@ Wing* FGFDM::parseWing(XMLAttributes* a, const char* type) w->setDihedral(attrf(a, "dihedral", defDihed) * DEG2RAD); w->setCamber(attrf(a, "camber", 0)); w->setIncidence(attrf(a, "incidence", 0) * DEG2RAD); + w->setTwist(attrf(a, "twist", 0) * DEG2RAD); // The 70% is a magic number that sorta kinda seems to match known // throttle settings to approach speed. diff --git a/src/FDM/YASim/Surface.cpp b/src/FDM/YASim/Surface.cpp index e03fb047c..3ac62b524 100644 --- a/src/FDM/YASim/Surface.cpp +++ b/src/FDM/YASim/Surface.cpp @@ -20,6 +20,7 @@ Surface::Surface() _chord = 0; _incidence = 0; + _twist = 0; _slatPos = _spoilerPos = _flapPos = 0; _slatDrag = _spoilerDrag = _flapDrag = 1; @@ -103,6 +104,11 @@ void Surface::setIncidence(float angle) _incidence = angle; } +void Surface::setTwist(float angle) +{ + _twist = angle; +} + void Surface::setSlatParams(float stallDelta, float dragPenalty) { _slatAlpha = stallDelta; @@ -160,7 +166,8 @@ void Surface::calcForce(float* v, float rho, float* out, float* torque) // "Rotate" by the incidence angle. Assume small angles, so we // need to diddle only the Z component, X is relatively unchanged // by small rotations. - out[2] += _incidence * out[0]; // z' = z + incidence * x + float incidence = _incidence + _twist; + out[2] += incidence * out[0]; // z' = z + incidence * x // Hold onto the local wind vector so we can multiply the induced // drag at the end. @@ -201,7 +208,7 @@ void Surface::calcForce(float* v, float rho, float* out, float* torque) // Reverse the incidence rotation to get back to surface // coordinates. - out[2] -= _incidence * out[0]; + out[2] -= incidence * out[0]; // Convert back to external coordinates Math::tmul33(_orient, out, out); diff --git a/src/FDM/YASim/Surface.hpp b/src/FDM/YASim/Surface.hpp index cbbbdf619..1b55e3c45 100644 --- a/src/FDM/YASim/Surface.hpp +++ b/src/FDM/YASim/Surface.hpp @@ -42,6 +42,9 @@ public: // positive is "up" (i.e. "positive AoA") void setIncidence(float angle); + // The offset from base incidence for this surface. + void setTwist(float angle); + void setTotalDrag(float c0); float getTotalDrag(); @@ -92,6 +95,7 @@ private: float _flapPos; float _spoilerPos; float _incidence; + float _twist; float _inducedDrag; }; diff --git a/src/FDM/YASim/Wing.cpp b/src/FDM/YASim/Wing.cpp index 42cbb3cfd..9899df8be 100644 --- a/src/FDM/YASim/Wing.cpp +++ b/src/FDM/YASim/Wing.cpp @@ -15,6 +15,7 @@ Wing::Wing() _stall = 0; _stallWidth = 0; _stallPeak = 0; + _twist = 0; _camber = 0; _incidence = 0; _inducedDrag = 1; @@ -114,6 +115,11 @@ void Wing::setStallPeak(float fraction) _stallPeak = fraction; } +void Wing::setTwist(float angle) +{ + _twist = angle; +} + void Wing::setCamber(float camber) { _camber = camber; @@ -324,6 +330,8 @@ void Wing::compile() // and flap1 are set. Right now flap1 overrides. int nSegs = (int)Math::ceil((end-start)/segLen); + if (_twist != 0 && nSegs < 16) // more segments if twisted + nSegs = 16; float segWid = _length * (end - start)/nSegs; int j; @@ -341,6 +349,7 @@ void Wing::compile() sr->surface = s; sr->weight = chord * segWid; s->setTotalDrag(sr->weight); + s->setTwist(_twist * Math::sqrt(1-frac)); _surfs.add(sr); if(_mirror) { @@ -351,6 +360,7 @@ void Wing::compile() sr->surface = s; sr->weight = chord * segWid; s->setTotalDrag(sr->weight); + s->setTwist(_twist * Math::sqrt(frac)); _surfs.add(sr); } } diff --git a/src/FDM/YASim/Wing.hpp b/src/FDM/YASim/Wing.hpp index 28eabf826..5052d7a26 100644 --- a/src/FDM/YASim/Wing.hpp +++ b/src/FDM/YASim/Wing.hpp @@ -27,6 +27,7 @@ public: void setStall(float aoa); void setStallWidth(float angle); void setStallPeak(float fraction); + void setTwist(float angle); void setCamber(float camber); void setIncidence(float incidence); void setInducedDrag(float drag) { _inducedDrag = drag; } @@ -92,6 +93,7 @@ private: float _stall; float _stallWidth; float _stallPeak; + float _twist; float _camber; float _incidence; float _inducedDrag; -- 2.39.5