&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");
}
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;
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)
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) {