From ea8bfba98adbdfea204b5b109077cb38a5b079a6 Mon Sep 17 00:00:00 2001 From: Henning Stahlke Date: Fri, 5 May 2017 16:25:16 +0200 Subject: [PATCH] YASim: add method to Wing and clarify member name. --- src/FDM/YASim/Wing.cpp | 18 +++++++++++++++--- src/FDM/YASim/Wing.hpp | 7 +++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/FDM/YASim/Wing.cpp b/src/FDM/YASim/Wing.cpp index 81aa4e3e9..e8c77be07 100644 --- a/src/FDM/YASim/Wing.cpp +++ b/src/FDM/YASim/Wing.cpp @@ -11,7 +11,7 @@ Wing::Wing(Version *ver, bool mirror, float* base, float chord, _chord(chord), _length(length), _taper(taper), - _sweep(sweep), + _sweepAngleCenterLine(sweep), _dihedral(dihedral), _twist(twist) { @@ -129,7 +129,7 @@ void Wing::calculateWingCoordinateSystem() { // (tail incidence is varied by the solver) // Generating a unit vector pointing out the left wing. float left[3]; - left[0] = -Math::tan(_sweep); + left[0] = -Math::tan(_sweepAngleCenterLine); left[1] = Math::cos(_dihedral); left[2] = Math::sin(_dihedral); Math::unit3(left, left); @@ -175,9 +175,21 @@ void Wing::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; + _macX = _base[0]-Math::tan(_sweepAngleCenterLine) * _macRootDistance + _mac/2; } +float Wing::calculateSweepAngleLeadingEdge() +{ + if (_length == 0) { + return 0; + } + return Math::atan( + (sin(_sweepAngleCenterLine)+(1-_taper)*_chord/(2*_length)) / + cos(_sweepAngleCenterLine) + ); +} + + void Wing::compile() { // Have we already been compiled? diff --git a/src/FDM/YASim/Wing.hpp b/src/FDM/YASim/Wing.hpp index e7496c61d..ac206bd4e 100644 --- a/src/FDM/YASim/Wing.hpp +++ b/src/FDM/YASim/Wing.hpp @@ -31,7 +31,7 @@ public: // fraction of chord at wing tip, 0..1 float getTaper() const { return _taper; }; // radians - float getSweep() const { return _sweep; }; + float getSweep() const { return _sweepAngleCenterLine; }; // radians, positive is "up" void setDihedral(float dihedral) { _dihedral = dihedral; } float getDihedral() const { return _dihedral; }; @@ -96,6 +96,7 @@ private: void calculateTip(); void calculateSpan(); void calculateMAC(); + float calculateSweepAngleLeadingEdge(); void addSurface(Surface* s, float weight, float twist); struct SurfRec { Surface * surface; float weight; }; @@ -110,9 +111,11 @@ private: bool _mirror {false}; float _base[3] {0,0,0}; float _chord {0}; + // length is distance from base to tip, not wing span float _length {0}; float _taper {1}; - float _sweep {0}; + // sweep of center line, not leading edge! + float _sweepAngleCenterLine {0}; float _dihedral {0}; // calculated from above