From 02d037d2053b2689971e06ca6abd58257b51c547 Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Sun, 7 Aug 2016 11:41:03 +0200 Subject: [PATCH] Fix the startup position error. I'll leave it to Bertrand wether this is the best way to fix it --- src/FDM/JSBSim/JSBSim.cxx | 2 +- src/FDM/JSBSim/models/flight_control/FGAngles.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) mode change 100644 => 100755 src/FDM/JSBSim/models/flight_control/FGAngles.cpp diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index 4e33296d1..dae6d4515 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -1055,7 +1055,7 @@ void FGJSBsim::set_Altitude(double alt) { SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Altitude: " << alt ); - if (needTrim) { + if (0){ // needTrim) { FGLocation position = fgic->GetPosition(); position.SetPositionGeodetic(0.0, position.GetGeodLatitudeRad(), alt); diff --git a/src/FDM/JSBSim/models/flight_control/FGAngles.cpp b/src/FDM/JSBSim/models/flight_control/FGAngles.cpp old mode 100644 new mode 100755 index 4c17a07a6..d17914a00 --- a/src/FDM/JSBSim/models/flight_control/FGAngles.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGAngles.cpp @@ -74,7 +74,7 @@ using namespace std; namespace JSBSim { -IDENT(IdSrc,"$Id: FGAngles.cpp,v 1.4 2014/01/13 10:46:07 ehofman Exp $"); +IDENT(IdSrc,"$Id: FGAngles.cpp,v 1.5 2016/07/27 22:42:47 andgi Exp $"); IDENT(IdHdr,ID_ANGLES); /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -145,7 +145,8 @@ bool FGAngles::Run(void ) double x2 = cos(target_angle); double y2 = sin(target_angle); - double angle_to_heading_rad = acos(x1*x2 + y1*y2); + double x1x2_y1y2 = max(-1.0, min(x1*x2 + y1*y2, 1.0)); + double angle_to_heading_rad = acos(x1x2_y1y2); double x1y2 = x1*y2; double x2y1 = x2*y1;