diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 1e6240570..4ad261adf 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -365,11 +365,8 @@ getMagDip () static double getHeadingMag () { - double magheading; - magheading = fgGetDouble("/orientation/heading-deg") - getMagVar(); - if (magheading <= 0) magheading += 360; - else if (magheading > 360) magheading -= 360; - return magheading; + double magheading = fgGetDouble("/orientation/heading-deg") - getMagVar(); + return SGMiscd::normalizePeriodic(0.5, 360.5, magheading ); } /** @@ -378,11 +375,8 @@ getHeadingMag () static double getTrackMag () { - double magtrack; - magtrack = fgGetDouble("/orientation/track-deg") - getMagVar(); - if (magtrack <= 0) magtrack += 360; - else if (magtrack > 360) magtrack -= 360; - return magtrack; + double magtrack = fgGetDouble("/orientation/track-deg") - getMagVar(); + return SGMiscd::normalizePeriodic(0.5, 360.5, magtrack ); } static bool