]> git.mxchange.org Git - simgear.git/commitdiff
Fix a NaN at higher altitudes: sin_beta could become greater than 1.0 which is hard...
authorehofman <ehofman>
Mon, 6 Apr 2009 19:24:29 +0000 (19:24 +0000)
committerTim Moore <timoore@redhat.com>
Wed, 15 Apr 2009 21:03:07 +0000 (23:03 +0200)
simgear/scene/sky/oursun.cxx

index 4ace0529cb6657aed43c935d8ab1f39475256f91..67bbc7235ebdb8d4a37516f52427d8031e05e9b5 100644 (file)
@@ -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