-time_t fgTimeSecondsUntilNoon( time_t cur_time,
- double lon_rad,
- double lat_rad )
-{
- // cout << "location = " << lon_rad * SG_RADIANS_TO_DEGREES << ", "
- // << lat_rad * SG_RADIANS_TO_DEGREES << endl;
- Point3D geod( lon_rad, lat_rad, 0 );
- Point3D tmp = sgGeodToCart( geod );
- sgVec3 world_up;
- sgSetVec3( world_up, tmp.x(), tmp.y(), tmp.z() );
- SGTime t = SGTime( lon_rad, lat_rad, "", 0 );
-
- double best_angle = 180.0;
- time_t best_time = cur_time;
-
- for ( time_t secs = cur_time; secs < cur_time + day_secs; secs += 300 ) {
- t.update( lon_rad, lat_rad, secs, 0 );
- double angle = sun_angle( t, world_up, lon_rad, lat_rad );
- if ( angle < best_angle ) {
- // cout << "best angle = " << angle << " offset = "
- // << secs - cur_time << endl;
- best_angle = angle;
- best_time = secs;
- }
- }
-
- if ( best_time > day_secs / 2 ) {
- best_time -= day_secs;
- }
-
- return best_time - cur_time;
-}
-
-
-/**
- * Given the current unix time in seconds, calculate seconds to midnight
- */
-time_t fgTimeSecondsUntilMidnight( time_t cur_time,