示例#1
0
        public void EscapeVelocity_ReturnsCorrectValue()
        {
            //  prereq
            Approx_Works();
            Scientific_Works();
            GravitationalAcceleration_FloatDataReturnsCorrectValue();

            //  arrange
            //  mean Earth radius (km => meters)
            float distance = (float)PMath.Scientific(6.371, 6);
            //  typical person mass (kg)
            float personMass = 70;
            //  Earth mass (kg)
            //  Ref: https://en.wikipedia.org/wiki/Earth_mass
            double earthMass = PMath.Scientific(5.97237, 24);

            //  force is m/s/s
            float force = PMath.GravitationalAcceleration(personMass, (float)earthMass, distance);

            //  escape velocity on earth is 11.2 km/s (km/s => m/s)
            float expected = 11.2f * 1000;

            //  act (m/s)
            double velocity = PMath.EscapeVelocity(force, distance);

            //  assert
            Assert.IsTrue(PMath.Approx(expected, (float)velocity, 1), "Escape Velocity: expected "
                          + expected + " m/s != actual " + velocity + " m/s");
        }