
//------------------------------------------------------------------------------
//--  Compute atmospheric characteristics at a given altitude below 11 km.    --
//--  The algorithm was extracted from the 1976 Standard Atmosphere code for  --
//--  the lowest altitude range.  See http://www.pdas.com/atmosf90.htm for    --
//--  the Fortran 90 code.                                                    --
//--                                                                          --
//--  Direct any questions to Eric Fahlgren at eric.fahlgren@mscsoftware.com. --

   function Delta(metersASL)
   {
      kmASL    = metersASL / 1000;

      radEarth = 6369.0;                // Radius of the Earth (km).
      GMR      = 34.163195;             // Gas constant.

      gpA      = kmASL*radEarth / (kmASL+radEarth); // Geopotential altitude.

      tGrad    = -6.5;
      tBase    = 288.15;                            // STP = 15 C.
      tLocal   = tBase + tGrad*gpA;
      delta    = Math.pow(tBase/tLocal, GMR/tGrad); // Pressure ratio.

      // These are unused, but here for reference.
      theta    = tLocal / tBase;                    // Temperature ratio.
      sigma    = delta / theta;                     // Density ratio.

      return delta;
   }

