1
0
Fork 0

division-by-zero fix from Csaba Halasz

This commit is contained in:
Tim Moore 2009-01-26 00:47:09 +01:00
parent d509343067
commit 194527a59a

View file

@ -436,15 +436,19 @@ FGMetarEnvironmentCtrl::update_env_config ()
// factor by the maximum wind change.
double x = fabs(current[0] - metar[0]);
double y = fabs(current[1] - metar[1]);
double dx = x / (x + y);
double dy = 1 - dx;
double maxdx = dx * MaxWindChangeKtsSec;
double maxdy = dy * MaxWindChangeKtsSec;
// only interpolate if we have a difference
if (x + y > 0) {
double dx = x / (x + y);
double dy = 1 - dx;
// Interpolate each component separately.
current[0] = interpolate_val(current[0], metar[0], maxdx);
current[1] = interpolate_val(current[1], metar[1], maxdy);
double maxdx = dx * MaxWindChangeKtsSec;
double maxdy = dy * MaxWindChangeKtsSec;
// Interpolate each component separately.
current[0] = interpolate_val(current[0], metar[0], maxdx);
current[1] = interpolate_val(current[1], metar[1], maxdy);
}
// Now convert back to polar coordinates.
if ((current[0] == 0.0) && (current[1] == 0.0)) {