444 :                   double x = fabs(current[0] - metar[0]);
445 :                   double y = fabs(current[1] - metar[1]);
446 :                   double dx = x / (x + y);
447 :                   double dy = 1 - dx;

I guess we could even compare the speed/direction values directly
before doing any conversion.

-- 
Csaba/Jester
Index: src/Environment/environment_ctrl.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Environment/environment_ctrl.cxx,v
retrieving revision 1.62
diff -u -r1.62 environment_ctrl.cxx
--- src/Environment/environment_ctrl.cxx	26 Dec 2008 15:33:38 -0000	1.62
+++ src/Environment/environment_ctrl.cxx	2 Jan 2009 23:13:47 -0000
@@ -443,15 +443,19 @@
         // 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;
-
-        // Interpolate each component separately.
-        current[0] = interpolate_val(current[0], metar[0], maxdx);
-        current[1] = interpolate_val(current[1], metar[1], maxdy);
+        // only interpolate if we have a difference
+        if (x + y > 0) {
+            double dx = x / (x + y);
+            double dy = 1 - dx;
+
+            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)) {
------------------------------------------------------------------------------
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to