Exemplo n.º 1
0
    def test_hyperbolic_orbital_parameters(self):
        # Unlike the elliptical test, this tests our favourite extra-solar
        # visitor to make sure we can calculate Keplerian orbital
        # characteristics from its orbital state vectors! That's right, we're
        # talking about Sedna! The expected values are arrived at through
        # calculation, and also
        # http://orbitsimulator.com/formulas/OrbitalElements.html
        physics_state = common.load_savefile(
            common.savefile('tests/sedna.json'))
        sun = physics_state[0]
        oumuamua = physics_state[1]

        expected_semimajor_axis = -71231070.14146987
        self.assertAlmostEqual(calc.semimajor_axis(oumuamua, sun),
                               expected_semimajor_axis,
                               delta=abs(0.01 * expected_semimajor_axis))

        expected_eccentricity = 1644.477
        self.assertAlmostEqual(calc.fastnorm(calc.eccentricity(oumuamua, sun)),
                               expected_eccentricity,
                               delta=0.01 * expected_eccentricity)

        expected_periapsis = 1.1714e11  # Through calculation
        self.assertAlmostEqual(calc.periapsis(sun, oumuamua) + oumuamua.r,
                               expected_periapsis,
                               delta=0.01 * 78989185420.15271)
Exemplo n.º 2
0
    def test_elliptical_orbital_parameters(self):
        # Again, see
        # https://www.wolframalpha.com/input/?i=International+Space+Station
        # For these expected values
        physics_state = common.load_savefile(
            common.savefile('tests/gui-test.json'))
        iss = physics_state[0]
        earth = physics_state[1]

        # The semiaxes are relatively close to expected.
        self.assertAlmostEqual(calc.semimajor_axis(iss, earth),
                               6785e3,
                               delta=0.01 * earth.r)

        # The eccentricity is within 1e-6 of the expected.
        self.assertAlmostEqual(calc.fastnorm(calc.eccentricity(iss, earth)),
                               5.893e-4,
                               delta=1e-3)

        # The apoapsis is relatively close to expected.
        self.assertAlmostEqual(calc.apoapsis(iss, earth),
                               418.3e3,
                               delta=0.01 * earth.r)

        # The periapsis is relatively close to expected.
        self.assertAlmostEqual(calc.periapsis(iss, earth),
                               410.3e3,
                               delta=0.01 * earth.r)