From 23cdb0d3020f5beca54bb72736163c88a520cdb2 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Wed, 4 Jan 2012 00:00:10 +0100 Subject: [PATCH] #561: keep magnetic heading within limits when mag-variation is negative Thanks to Hyde! --- src/Main/fg_props.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index c12026434..1e6240570 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -367,7 +367,8 @@ getHeadingMag () { double magheading; magheading = fgGetDouble("/orientation/heading-deg") - getMagVar(); - if (magheading < 0) magheading += 360; + if (magheading <= 0) magheading += 360; + else if (magheading > 360) magheading -= 360; return magheading; } @@ -379,7 +380,8 @@ getTrackMag () { double magtrack; magtrack = fgGetDouble("/orientation/track-deg") - getMagVar(); - if (magtrack < 0) magtrack += 360; + if (magtrack <= 0) magtrack += 360; + else if (magtrack > 360) magtrack -= 360; return magtrack; }