private static void ConversionIntegrityTest(float altitude)
        {
            float derivedPressure = StaticPressureHelper.GetPressure(altitude, SeaLevelStaticPressure);
            float derivedAltitude = StaticPressureHelper.GetAltitude(derivedPressure, SeaLevelStaticPressure);

            AssertWithin(derivedAltitude, altitude, 0.001f);
        }
Exemplo n.º 2
0
        public override void Update(PhysicalHeliState startState, PhysicalHeliState endState, JoystickOutput output, TimeSpan totalSimulationTime, TimeSpan endTime)
        {
            PhysicalHeliState stateToMeasure = endState;
            float             trueAltitude   = stateToMeasure.Position.Y;

            if (IsPerfect)
            {
                Altitude = trueAltitude;
            }
            else
            {
                float simulatedPressure = _pressureProvider.GetSimulatedStaticPressure(trueAltitude);
                Altitude = StaticPressureHelper.GetAltitude(simulatedPressure, SeaLevelStaticPressure);
            }
        }
        public void GetAltitudeTest()
        {
            float pressure, expected, actual;


            // All expected values are taken from a lookup table
            pressure = 22632;
            expected = 11000;
            actual   = StaticPressureHelper.GetAltitude(pressure, SeaLevelStaticPressure);
            AssertWithin(actual, expected, 100);

            pressure = 101325;
            expected = 0;
            actual   = StaticPressureHelper.GetAltitude(pressure, SeaLevelStaticPressure);
            AssertWithin(actual, expected, 100);

            pressure = 54019;
            expected = 5000;
            actual   = StaticPressureHelper.GetAltitude(pressure, SeaLevelStaticPressure);
            AssertWithin(actual, expected, 100);
        }