From 254de7695d347b8ca844ddf9e09add61b762d292 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 19 Feb 2002 16:25:38 +0000 Subject: [PATCH] Further tweaks for the new environment subsystem. --- src/Environment/environment.cxx | 14 ++++++++++---- src/Main/options.cxx | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Environment/environment.cxx b/src/Environment/environment.cxx index c8703b338..6fd317a74 100644 --- a/src/Environment/environment.cxx +++ b/src/Environment/environment.cxx @@ -84,15 +84,15 @@ FGEnvironment::bind () &FGEnvironment::get_wind_speed_kt, &FGEnvironment::set_wind_speed_kt); fgTie("/environment/wind-from-north-fps", this, &FGEnvironment::get_wind_from_north_fps, - &FGEnvironment::set_wind_from_north_fps, false); + &FGEnvironment::set_wind_from_north_fps); fgSetArchivable("/environment/wind-from-north-fps"); fgTie("/environment/wind-from-east-fps", this, &FGEnvironment::get_wind_from_east_fps, - &FGEnvironment::set_wind_from_east_fps, false); + &FGEnvironment::set_wind_from_east_fps); fgSetArchivable("/environment/wind-from-east-fps"); fgTie("/environment/wind-from-down-fps", this, &FGEnvironment::get_wind_from_down_fps, - &FGEnvironment::set_wind_from_down_fps, false); + &FGEnvironment::set_wind_from_down_fps); fgSetArchivable("/environment/wind-from-down-fps"); } @@ -176,7 +176,13 @@ FGEnvironment::set_wind_from_down_fps (double d) void FGEnvironment::_recalc_hdgspd () { - double angle_rad = atan(wind_from_north_fps/wind_from_east_fps); + double angle_rad; + + if (wind_from_east_fps == 0) { + angle_rad = (wind_from_north_fps >= 0 ? SGD_PI/2 : -SGD_PI/2); + } else { + angle_rad = atan(wind_from_north_fps/wind_from_east_fps); + } wind_from_heading_deg = angle_rad * SGD_RADIANS_TO_DEGREES; if (wind_from_east_fps >= 0) wind_from_heading_deg = 90 - wind_from_heading_deg; diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 6ed75c849..5fbc483fa 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -900,8 +900,9 @@ parse_option (const string& arg) SG_LOG(SG_GENERAL, SG_INFO, "WIND: " << dir << '@' << speed << " knots" << endl); fgSetDouble("/environment/wind-from-heading-deg", dir); - fgSetDouble("/environment/wind-speed-knots", speed); + fgSetDouble("/environment/wind-speed-kt", speed); +#if !defined (FG_NEW_ENVIRONMENT) // convert to fps speed *= SG_NM_TO_METER * SG_METER_TO_FEET * (1.0/3600); while (dir > 360) @@ -913,6 +914,7 @@ parse_option (const string& arg) speed * cos(dir)); fgSetDouble("/environment/wind-from-east-fps", speed * sin(dir)); +#endif // FG_NEW_ENVIRONMENT } else if ( arg.find( "--wp=" ) == 0 ) { parse_wp( arg.substr( 5 ) ); } else if ( arg.find( "--flight-plan=") == 0) {