1
0
Fork 0

Further tweaks for the new environment subsystem.

This commit is contained in:
david 2002-02-19 16:25:38 +00:00
parent ee3500a0a4
commit 254de7695d
2 changed files with 13 additions and 5 deletions

View file

@ -84,15 +84,15 @@ FGEnvironment::bind ()
&FGEnvironment::get_wind_speed_kt, &FGEnvironment::set_wind_speed_kt); &FGEnvironment::get_wind_speed_kt, &FGEnvironment::set_wind_speed_kt);
fgTie("/environment/wind-from-north-fps", this, fgTie("/environment/wind-from-north-fps", this,
&FGEnvironment::get_wind_from_north_fps, &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"); fgSetArchivable("/environment/wind-from-north-fps");
fgTie("/environment/wind-from-east-fps", this, fgTie("/environment/wind-from-east-fps", this,
&FGEnvironment::get_wind_from_east_fps, &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"); fgSetArchivable("/environment/wind-from-east-fps");
fgTie("/environment/wind-from-down-fps", this, fgTie("/environment/wind-from-down-fps", this,
&FGEnvironment::get_wind_from_down_fps, &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"); fgSetArchivable("/environment/wind-from-down-fps");
} }
@ -176,7 +176,13 @@ FGEnvironment::set_wind_from_down_fps (double d)
void void
FGEnvironment::_recalc_hdgspd () 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; wind_from_heading_deg = angle_rad * SGD_RADIANS_TO_DEGREES;
if (wind_from_east_fps >= 0) if (wind_from_east_fps >= 0)
wind_from_heading_deg = 90 - wind_from_heading_deg; wind_from_heading_deg = 90 - wind_from_heading_deg;

View file

@ -900,8 +900,9 @@ parse_option (const string& arg)
SG_LOG(SG_GENERAL, SG_INFO, "WIND: " << dir << '@' << SG_LOG(SG_GENERAL, SG_INFO, "WIND: " << dir << '@' <<
speed << " knots" << endl); speed << " knots" << endl);
fgSetDouble("/environment/wind-from-heading-deg", dir); 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 // convert to fps
speed *= SG_NM_TO_METER * SG_METER_TO_FEET * (1.0/3600); speed *= SG_NM_TO_METER * SG_METER_TO_FEET * (1.0/3600);
while (dir > 360) while (dir > 360)
@ -913,6 +914,7 @@ parse_option (const string& arg)
speed * cos(dir)); speed * cos(dir));
fgSetDouble("/environment/wind-from-east-fps", fgSetDouble("/environment/wind-from-east-fps",
speed * sin(dir)); speed * sin(dir));
#endif // FG_NEW_ENVIRONMENT
} else if ( arg.find( "--wp=" ) == 0 ) { } else if ( arg.find( "--wp=" ) == 0 ) {
parse_wp( arg.substr( 5 ) ); parse_wp( arg.substr( 5 ) );
} else if ( arg.find( "--flight-plan=") == 0) { } else if ( arg.find( "--flight-plan=") == 0) {