]> git.mxchange.org Git - flightgear.git/commitdiff
When the turn angle is large, don’t fly-by.
authorJames Turner <zakalawe@mac.com>
Mon, 22 Dec 2014 18:47:21 +0000 (21:47 +0300)
committerJames Turner <zakalawe@mac.com>
Mon, 22 Dec 2014 18:47:21 +0000 (21:47 +0300)
This avoids the tan() term in the fly-by computation
causing huge turn cuts which will fail to sequence.
Convert such turns to fly-over.

src/Navaids/routePath.cxx

index 0f9700f6540efb210c3c879007b46ee08daafd19..46150b603cec4150098a0144833a4af4b553836d 100644 (file)
@@ -175,9 +175,15 @@ public:
     turnAngle = next.legCourseTrue - legCourseTrue;
     SG_NORMALIZE_RANGE(turnAngle, -180.0, 180.0);
     turnRadius = radiusM;
-    
     double p = copysign(90.0, turnAngle);
 
+    if (fabs(turnAngle) > 120.0) {
+        // flyBy logic blows up for sharp turns - due to the tan() term
+        // heading towards infinity. By converting to flyOver we do something
+        // closer to what was requested.
+        flyOver = true;
+    }
+
     if (flyOver) {
       turnEntryPos = pos;
       turnCenter = SGGeodesy::direct(pos, legCourseTrue + p, turnRadius);
@@ -222,10 +228,10 @@ public:
           next.legCourseTrue = SGGeodesy::courseDeg(turnExitPos, next.pos);
 
           turnPathDistanceM = turnRadius * (fabs(turnAngle) * SG_DEGREES_TO_RADIANS);
-        }
+        } // of next leg isn't course constrained
       } else {
           // next point is dynamic
-          // no compentsation needed
+          // no compensation needed
           turnPathDistanceM = turnRadius * (fabs(turnAngle) * SG_DEGREES_TO_RADIANS);
       }
     } else {