From 9c637e6b2af1cadba9e17f71569ebe1d61fbc912 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Wed, 8 Jul 2015 11:14:46 +0200 Subject: [PATCH] UFO and MagicCarpet FDM: avoid negative headings Both FDM set the heading to negative values when turning left through north. This should be fixed by this commit. --- src/FDM/SP/MagicCarpet.cxx | 2 +- src/FDM/UFO.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FDM/SP/MagicCarpet.cxx b/src/FDM/SP/MagicCarpet.cxx index 822c1aa89..d5b202ac8 100644 --- a/src/FDM/SP/MagicCarpet.cxx +++ b/src/FDM/SP/MagicCarpet.cxx @@ -81,7 +81,7 @@ void FGMagicCarpet::update( double dt ) { // update euler angles _set_Euler_Angles( get_Phi(), get_Theta(), - fmod(get_Psi() + turn, SGD_2PI) ); + SGMiscd::normalizePeriodic(0, SGD_2PI, get_Psi() + turn) ); _set_Euler_Rates(0,0,0); // update (lon/lat) position diff --git a/src/FDM/UFO.cxx b/src/FDM/UFO.cxx index edb56c0bb..6e2c54e4b 100644 --- a/src/FDM/UFO.cxx +++ b/src/FDM/UFO.cxx @@ -173,7 +173,7 @@ void FGUFO::update( double dt ) { sgGeodToGeoc( get_Latitude(), get_Altitude(), &sl_radius, &lat_geoc ); // update euler angles - double heading = fmod(get_Psi() + turn + yaw, SGD_2PI); + double heading = SGMiscd::normalizePeriodic(0, SGD_2PI, get_Psi() + turn + yaw ); _set_Euler_Angles(roll, pitch, heading); _set_Euler_Rates(0,0,0); -- 2.39.5