Fix a problem where the dot product might possibly be greater than 1.0 causing a NaN for the following acos()
This commit is contained in:
parent
7720fd5f99
commit
ce66c93d6c
1 changed files with 6 additions and 0 deletions
|
@ -341,6 +341,12 @@ void fgUpdateSunPos( void ) {
|
||||||
dot = sgScalarProductVec3( surface_to_sun, v->get_surface_south() );
|
dot = sgScalarProductVec3( surface_to_sun, v->get_surface_south() );
|
||||||
// cout << " Dot product = " << dot << endl;
|
// 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 ) {
|
if ( east_dot >= 0 ) {
|
||||||
l->set_sun_rotation( acos(dot) );
|
l->set_sun_rotation( acos(dot) );
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue