Update of /cvsroot/jsbsim/JSBSim/src/models/flight_control
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5071/src/models/flight_control
Modified Files:
FGAngles.cpp
Log Message:
Make sure the argument to acos() is never out of bounds.
Index: FGAngles.cpp
===================================================================
RCS file: /cvsroot/jsbsim/JSBSim/src/models/flight_control/FGAngles.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** FGAngles.cpp 13 Jan 2014 10:46:07 -0000 1.4
--- FGAngles.cpp 27 Jul 2016 22:42:47 -0000 1.5
***************
*** 146,150 ****
double y2 = sin(target_angle);
! double angle_to_heading_rad = acos(x1*x2 + y1*y2);
double x1y2 = x1*y2;
double x2y1 = x2*y1;
--- 146,151 ----
double y2 = sin(target_angle);
! 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;
|