division-by-zero fix from Csaba Halasz
This commit is contained in:
parent
d509343067
commit
194527a59a
1 changed files with 11 additions and 7 deletions
|
@ -436,6 +436,9 @@ FGMetarEnvironmentCtrl::update_env_config ()
|
||||||
// factor by the maximum wind change.
|
// factor by the maximum wind change.
|
||||||
double x = fabs(current[0] - metar[0]);
|
double x = fabs(current[0] - metar[0]);
|
||||||
double y = fabs(current[1] - metar[1]);
|
double y = fabs(current[1] - metar[1]);
|
||||||
|
|
||||||
|
// only interpolate if we have a difference
|
||||||
|
if (x + y > 0) {
|
||||||
double dx = x / (x + y);
|
double dx = x / (x + y);
|
||||||
double dy = 1 - dx;
|
double dy = 1 - dx;
|
||||||
|
|
||||||
|
@ -445,6 +448,7 @@ FGMetarEnvironmentCtrl::update_env_config ()
|
||||||
// Interpolate each component separately.
|
// Interpolate each component separately.
|
||||||
current[0] = interpolate_val(current[0], metar[0], maxdx);
|
current[0] = interpolate_val(current[0], metar[0], maxdx);
|
||||||
current[1] = interpolate_val(current[1], metar[1], maxdy);
|
current[1] = interpolate_val(current[1], metar[1], maxdy);
|
||||||
|
}
|
||||||
|
|
||||||
// Now convert back to polar coordinates.
|
// Now convert back to polar coordinates.
|
||||||
if ((current[0] == 0.0) && (current[1] == 0.0)) {
|
if ((current[0] == 0.0) && (current[1] == 0.0)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue