+// Convert altitude to air pressure by ICAO Standard Atmosphere
+double altFtToPressInHg(double alt_ft)
+{
+ // Ref. Aviation Formulary, Ed Williams, www.best.com/~williams/avform.htm
+ const double P_0 = 29.92126; // Std. MSL pressure, inHg. (=1013.25 mb)
+ const double p_Tr = 0.2233609 * P_0; // Pressure at tropopause, same units.
+ const double h_Tr = 36089.24; // Alt of tropopause, ft. (=11.0 km)
+
+ if (alt_ft < h_Tr) // 0.0 to 11.0 km
+ return P_0 * pow(1.0 - 6.8755856e-6 * alt_ft, 5.2558797);
+ return p_Tr * exp(-4.806346e-5 * (alt_ft - h_Tr)); // 11.0 to 20.0 km
+ // We could put more code for higher altitudes here.
+}
+
+