]> git.mxchange.org Git - flightgear.git/commitdiff
Fix for issue 1394 (YASim's geometry for non-cylindrical fuselages is wrong)
authorColin Douglas Howell <colin.d.howell@gmail.com>
Tue, 6 May 2014 04:21:23 +0000 (21:21 -0700)
committerTorsten Dreyer <torsten@t3r.de>
Tue, 6 May 2014 08:38:48 +0000 (10:38 +0200)
Correct handling of fuselage's "midpoint" XML attribute so that the midpoint's
location matches the point assumed by all aircraft developers and YASim docs.
This means the fuselage won't be generated "back-to-front".
Also correct the variation of diameter for tapered fuselages so that both ends
of the fuselage narrow from the midpoint to the endpoints.
Before this, one end was narrowing from the endpoint to the midpoint, the
opposite of what was expected.
These changes affect both weight distribution and the distribution of lateral
aerodynamic forces.

src/FDM/YASim/Airplane.cpp
src/FDM/YASim/FGFDM.cpp

index 3058718661ed67dd986a67e5fb739b41267f5eac..7826fad10543aa3c14048d39e0bbaf5b1a1e89ec 100644 (file)
@@ -530,8 +530,15 @@ float Airplane::compileFuselage(Fuselage* f)
         float scale = 1;
         if(frac < f->mid)
             scale = f->taper+(1-f->taper) * (frac / f->mid);
-        else
-            scale = f->taper+(1-f->taper) * (frac - f->mid) / (1 - f->mid);
+        else {
+           if( isVersionOrNewer( YASIM_VERSION_32 ) ) {
+               // Correct calculation of width for fuselage taper.
+               scale = 1 - (1-f->taper) * (frac - f->mid) / (1 - f->mid);
+           } else {
+               // Original, incorrect calculation of width for fuselage taper.
+               scale = f->taper+(1-f->taper) * (frac - f->mid) / (1 - f->mid);
+           }
+       }
 
         // Where are we?
         float pos[3];
index 1c722eac9397f0acb11836a3a15806f7271cbacd..e6e720385d6d5728bfa752153afcf56c2a0fe3bd 100644 (file)
@@ -436,6 +436,15 @@ void FGFDM::startElement(const char* name, const XMLAttributes &atts)
        b[2] = attrf(a, "bz");
         float taper = attrf(a, "taper", 1);
         float mid = attrf(a, "midpoint", 0.5);
+       if (_airplane.isVersionOrNewer(Version::YASIM_VERSION_32)) {
+           // A fuselage's "midpoint" XML attribute is defined from the
+            // fuselage's front end, but the Fuselage object's internal
+            // "mid" attribute is actually defined from the rear end.
+           // Thus YASim's original interpretation of "midpoint" was wrong.
+            // Complement the "midpoint" value to ensure the fuselage
+            // points the right way.
+           mid = 1 - mid;
+       }
         float cx = attrf(a, "cx", 1);
         float cy = attrf(a, "cy", 1);
         float cz = attrf(a, "cz", 1);