From 6feca9206034cc3c786958502e0a67ae0c21c56a Mon Sep 17 00:00:00 2001 From: Henning Stahlke Date: Wed, 22 Nov 2017 09:25:23 +0100 Subject: [PATCH] YASIM add struct StallParams to Wing --- src/FDM/YASim/FGFDM.cpp | 10 ++++++---- src/FDM/YASim/Wing.cpp | 14 +++++++------- src/FDM/YASim/Wing.hpp | 15 +++++++++------ 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/FDM/YASim/FGFDM.cpp b/src/FDM/YASim/FGFDM.cpp index 5bad06e85..3e5df51d2 100644 --- a/src/FDM/YASim/FGFDM.cpp +++ b/src/FDM/YASim/FGFDM.cpp @@ -534,10 +534,12 @@ void FGFDM::startElement(const char* name, const XMLAttributes &atts) } else if(eq(name, "weight")) { parseWeight(a); } else if(eq(name, "stall")) { - Wing* w = (Wing*)_currObj; - w->setStall(attrf(a, "aoa") * DEG2RAD); - w->setStallWidth(attrf(a, "width", 2) * DEG2RAD); - w->setStallPeak(attrf(a, "peak", 1.5)); + Wing* w = (Wing*)_currObj; + StallParams sp; + sp.aoa = attrf(a, "aoa") * DEG2RAD; + sp.width = attrf(a, "width", 2) * DEG2RAD; + sp.peak = attrf(a, "peak", 1.5); + w->setStallParams(sp); } else if(eq(name, "flap0") || eq(name, "flap1") || eq(name, "spoiler") || eq(name, "slat")) { FlapParams fp; fp.start = attrf(a, "start"); diff --git a/src/FDM/YASim/Wing.cpp b/src/FDM/YASim/Wing.cpp index f83c91c79..dc87a4aed 100644 --- a/src/FDM/YASim/Wing.cpp +++ b/src/FDM/YASim/Wing.cpp @@ -297,27 +297,27 @@ Surface* Wing::newSurface(float* pos, float* orient, float chord, s->setChord(chord); // Camber is expressed as a fraction of stall peak, so convert. - s->setBaseZDrag(_camber*_stallPeak); + s->setBaseZDrag(_camber*_stallParams.peak); // The "main" (i.e. normal) stall angle - float stallAoA = _stall - _stallWidth/4; + float stallAoA = _stallParams.aoa - _stallParams.width/4; s->setStall(0, stallAoA); - s->setStallWidth(0, _stallWidth); - s->setStallPeak(0, _stallPeak); + s->setStallWidth(0, _stallParams.width); + s->setStallPeak(0, _stallParams.peak); // The negative AoA stall is the same if we're using an symmetric // airfoil, otherwise a "little worse". if(_camber > 0) { s->setStall(1, stallAoA * 0.8f); - s->setStallWidth(1, _stallWidth * 0.5f); + s->setStallWidth(1, _stallParams.width * 0.5f); } else { s->setStall(1, stallAoA); if( _version->isVersionOrNewer( Version::YASIM_VERSION_2017_2 )) { // what was presumably meant - s->setStallWidth(1, _stallWidth); + s->setStallWidth(1, _stallParams.width); } else { // old code; presumably a copy&paste error - s->setStall(1, _stallWidth); + s->setStall(1, _stallParams.width); } } diff --git a/src/FDM/YASim/Wing.hpp b/src/FDM/YASim/Wing.hpp index 8b7f10f64..447878627 100644 --- a/src/FDM/YASim/Wing.hpp +++ b/src/FDM/YASim/Wing.hpp @@ -19,6 +19,12 @@ struct FlapParams { float aoa {0}; }; +struct StallParams { + float aoa {0}; + float width {0}; + float peak {0}; +}; + // position and length of a chord line struct Chord { float x {0}; @@ -65,9 +71,7 @@ public: // parameters for stall curve - void setStall(float aoa) { _stall = aoa; } - void setStallWidth(float angle) { _stallWidth = angle; } - void setStallPeak(float fraction) { _stallPeak = fraction; } + void setStallParams(StallParams sp) { _stallParams = sp; } void setCamber(float camber) { _camber = camber; } void setInducedDrag(float drag) { _inducedDrag = drag; } @@ -151,9 +155,8 @@ private: float _wingspan {0}; float _aspectRatio {1}; - float _stall {0}; - float _stallWidth {0}; - float _stallPeak {0}; + StallParams _stallParams; + float _twist {0}; float _camber {0}; float _incidence {0};