]> git.mxchange.org Git - flightgear.git/blobdiff - src/Systems/pitot.cxx
Make a subtle change to tile loading/unloading policy in order to make the tile
[flightgear.git] / src / Systems / pitot.cxx
index 3cd8f948543ba25c810b351c233085f2e5a312e2..5cfc6188b20ad514bbe96d5fba8ff99d946c78f2 100644 (file)
@@ -22,7 +22,7 @@ PitotSystem::init ()
     _serviceable_node = fgGetNode("/systems/pitot[0]/serviceable", true);
     _pressure_node = fgGetNode("/environment/pressure-inhg", true);
     _density_node = fgGetNode("/environment/density-slugft3", true);
-    _velocity_node = fgGetNode("/velocities/uBody-fps", true);
+    _velocity_node = fgGetNode("/velocities/airspeed-kt", true);
     _total_pressure_node =
         fgGetNode("/systems/pitot[0]/total-pressure-inhg", true);
 }
@@ -41,17 +41,26 @@ PitotSystem::unbind ()
 # define INHGTOPSF (2116.217/29.9212)
 #endif
 
+#ifndef PSFTOINHG
+# define PSFTOINHG (1/INHGTOPSF)
+#endif
+
+#ifndef KTTOFPS
+# define KTTOFPS 1.68781
+#endif
+
+
 void
 PitotSystem::update (double dt)
 {
     if (_serviceable_node->getBoolValue()) {
                                 // The pitot tube sees the forward
                                 // velocity in the body axis.
-        double p = _pressure_node->getDoubleValue(); // static
+        double p = _pressure_node->getDoubleValue() * INHGTOPSF;
         double r = _density_node->getDoubleValue();
-        double v = _velocity_node->getDoubleValue();
-        double q = 0.5 * r * v * v / INHGTOPSF; // dynamic
-        _total_pressure_node->setDoubleValue(p + q);
+        double v = _velocity_node->getDoubleValue() * KTTOFPS;
+        double q = 0.5 * r * v * v; // dynamic
+        _total_pressure_node->setDoubleValue((p + q) * PSFTOINHG);
     }
 }