]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/YASim/Wing.cpp
simplify name/number handling
[flightgear.git] / src / FDM / YASim / Wing.cpp
index 9899df8be6d395e0fc449869c53d0c294589f52f..12fb438f1482ba8919becf109575256576e17486 100644 (file)
@@ -235,22 +235,25 @@ void Wing::compile()
     // Have we already been compiled?
     if(_surfs.size() != 0) return;
 
-    // Assemble the start/end coordinates into an array, sort them,
+    // Assemble the start/end coordinates of all control surfaces
+    // and the wing itself into an array, sort them,
     // and remove duplicates.  This gives us the boundaries of our
     // segments.
-    float bounds[8];
+    float bounds[10];
     bounds[0] = _flap0Start;   bounds[1] = _flap0End;
     bounds[2] = _flap1Start;   bounds[3] = _flap1End;
     bounds[4] = _spoilerStart; bounds[5] = _spoilerEnd;
     bounds[6] = _slatStart;    bounds[7] = _slatEnd;
+    //and don't forget the root and the tip of the wing itself
+    bounds[8] = 0;             bounds[9] = 1;
 
     // Sort in increasing order
     int i;
-    for(i=0; i<8; i++) {
+    for(i=0; i<10; i++) {
         int minIdx = i;
        float minVal = bounds[i];
         int j;
-        for(j=i+1; j<8; j++) {
+        for(j=i+1; j<10; j++) {
             if(bounds[j] < minVal) {
                 minIdx = j;
                minVal = bounds[j];
@@ -259,11 +262,11 @@ void Wing::compile()
         float tmp = bounds[i];
         bounds[i] = minVal; bounds[minIdx] = tmp;
     }
-                                 
+
     // Uniqify
     float last = bounds[0];
     int nbounds = 1;
-    for(i=1; i<8; i++) {
+    for(i=1; i<10; i++) {
         if(bounds[i] != last)
             bounds[nbounds++] = bounds[i];
         last = bounds[i];
@@ -330,8 +333,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;
+        if (_twist != 0 && nSegs < 8) // more segments if twisted
+            nSegs = 8;
         float segWid = _length * (end - start)/nSegs;
 
         int j;
@@ -349,7 +352,7 @@ void Wing::compile()
             sr->surface = s;
             sr->weight = chord * segWid;
             s->setTotalDrag(sr->weight);
-            s->setTwist(_twist * Math::sqrt(1-frac));
+            s->setTwist(_twist * frac);
             _surfs.add(sr);
 
             if(_mirror) {
@@ -360,7 +363,7 @@ void Wing::compile()
                 sr->surface = s;
                 sr->weight = chord * segWid;
                 s->setTotalDrag(sr->weight);
-                s->setTwist(_twist * Math::sqrt(frac));
+                s->setTwist(_twist * frac);
                 _surfs.add(sr);
             }
         }
@@ -433,7 +436,7 @@ Surface* Wing::newSurface(float* pos, float* orient, float chord,
     int i;
     for(i=2; i<4; i++) {
         s->setStall(i, 0.2267f);
-        s->setStallWidth(i, 1);
+        s->setStallWidth(i, 0.01);
     }
     
     if(flap0)   s->setFlapParams(_flap0Lift, _flap0Drag);