From ce66c93d6ca89d1c5e6e26a578a8be7ad613a102 Mon Sep 17 00:00:00 2001 From: ehofman Date: Mon, 19 Jan 2004 13:46:47 +0000 Subject: [PATCH] Fix a problem where the dot product might possibly be greater than 1.0 causing a NaN for the following acos() --- src/Time/sunpos.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Time/sunpos.cxx b/src/Time/sunpos.cxx index 81f2d87b1..0b1e03f59 100644 --- a/src/Time/sunpos.cxx +++ b/src/Time/sunpos.cxx @@ -341,6 +341,12 @@ void fgUpdateSunPos( void ) { dot = sgScalarProductVec3( surface_to_sun, v->get_surface_south() ); // cout << " Dot product = " << dot << endl; + if (dot > 1) { + SG_LOG( SG_ASTRO, SG_WARN, + "Dot product = " << dot << " is greater than 1.0" ); + dot = 1.0; + } + if ( east_dot >= 0 ) { l->set_sun_rotation( acos(dot) ); } else { -- 2.39.2