From: Colin Douglas Howell Date: Tue, 6 May 2014 04:21:23 +0000 (-0700) Subject: Fix for issue 1394 (YASim's geometry for non-cylindrical fuselages is wrong) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4d1aebad793b8fd030c29a1503c75686f31fa4e8;p=flightgear.git Fix for issue 1394 (YASim's geometry for non-cylindrical fuselages is wrong) 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. --- diff --git a/src/FDM/YASim/Airplane.cpp b/src/FDM/YASim/Airplane.cpp index 305871866..7826fad10 100644 --- a/src/FDM/YASim/Airplane.cpp +++ b/src/FDM/YASim/Airplane.cpp @@ -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]; diff --git a/src/FDM/YASim/FGFDM.cpp b/src/FDM/YASim/FGFDM.cpp index 1c722eac9..e6e720385 100644 --- a/src/FDM/YASim/FGFDM.cpp +++ b/src/FDM/YASim/FGFDM.cpp @@ -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);