From 58f3985567a8df801a04a757e0466f8c74f43061 Mon Sep 17 00:00:00 2001 From: ehofman Date: Mon, 6 Apr 2009 19:24:29 +0000 Subject: [PATCH] Fix a NaN at higher altitudes: sin_beta could become greater than 1.0 which is hard to understand for asin. --- simgear/scene/sky/oursun.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/simgear/scene/sky/oursun.cxx b/simgear/scene/sky/oursun.cxx index 4ace0529..67bbc723 100644 --- a/simgear/scene/sky/oursun.cxx +++ b/simgear/scene/sky/oursun.cxx @@ -396,6 +396,7 @@ bool SGSun::reposition( double rightAscension, double declination, double gamma = SG_PI - sun_angle; double sin_beta = ( position_radius * sin ( gamma ) ) / r_tropo; + if (sin_beta > 1.0) sin_beta = 1.0; double alpha = SG_PI - gamma - asin( sin_beta ); // OK, now let's calculate the distance the light travels -- 2.39.5