diff --git a/src/QGC.cc b/src/QGC.cc index 50eb1c01754cac4f0018f8438ed6e68eb58901da..3237fadf3082d28f1f3864b15e75f8c5e3211b51 100644 --- a/src/QGC.cc +++ b/src/QGC.cc @@ -73,7 +73,7 @@ float limitAngleToPMPIf(float angle) else { // Approximate - angle = fmodf(angle, (float) M_PI); + angle = fmodf(angle, (float)M_PI); } return angle; diff --git a/src/ui/HUD.cc b/src/ui/HUD.cc index 8d80aad67aba346e114d31664f445a235e2619fc..8934fd8ced94e829d55d7dfadb29f2b5911a99e8 100644 --- a/src/ui/HUD.cc +++ b/src/ui/HUD.cc @@ -464,7 +464,7 @@ void HUD::paintCenterBackground(float roll, float pitch, float yaw) glTranslatef(referenceWidth/2.0f,referenceHeight/2.0f,0); // Move based on the yaw difference - glTranslatef(yaw, 0.0f, 0.0f); + //glTranslatef(yaw, 0.0f, 0.0f); // Rotate based on the bank glRotatef((roll/M_PI)*180.0f, 0.0f, 0.0f, 1.0f); @@ -788,8 +788,11 @@ void HUD::paintHUD() // const float yawDeg = ((values.value("yaw", 0.0f)/M_PI)*180.0f)+180.f; - // YAW is in compass-human readable format, so 0 - 360deg. This is normal in aviation, not -180 - +180. - const float yawDeg = ((yawLP/M_PI)*180.0f)+180.0f+180.0f; + // YAW is in compass-human readable format, so 0 .. 360 deg. + float yawDeg = ((yawLP/M_PI)*180.0f)+180.0f; + if (yawDeg < 0) yawDeg += 360; + if (yawDeg > 360) yawDeg -= 360; + /* final safeguard for really stupid systems */ int yawCompass = static_cast(yawDeg) % 360; yawAngle.sprintf("%03d", yawCompass); paintText(yawAngle, defaultColor, 3.5f, -4.3f, compassY+ 0.97f, &painter);