예제 #1
0
 def test_kerbin(self):
     kerbin = self.space_center.bodies['Kerbin']
     self.assertEqual('Kerbin', kerbin.name)
     self.assertAlmostEqual(5.2915158e22, kerbin.mass, delta=0.0001e22)
     self.assertAlmostEqual(3.5316000e12,
                            kerbin.gravitational_parameter,
                            delta=0.0001e12)
     self.assertAlmostEqual(9.81, kerbin.surface_gravity, places=2)
     self.assertAlmostEqual(21549.425, kerbin.rotational_period, delta=0.1)
     self.assertAlmostEqual((2 * 3.14159) / 21549.425,
                            kerbin.rotational_speed,
                            delta=0.1)
     self.assertAlmostEqual(math.pi / 2, kerbin.initial_rotation, delta=0.1)
     self.assertDegreesAlmostEqual(
         rad2deg(kerbin.initial_rotation +
                 (self.space_center.ut * kerbin.rotational_speed)),
         rad2deg(kerbin.rotation_angle),
         delta=0.1)
     self.assertAlmostEqual(600000, kerbin.equatorial_radius)
     self.assertAlmostEqual(8.4159e7,
                            kerbin.sphere_of_influence,
                            delta=0.0001e7)
     self.assertAlmostEqual(1.36e10, kerbin.orbit.apoapsis, delta=0.0001e10)
     self.assertAlmostEqual(1.36e10,
                            kerbin.orbit.periapsis,
                            delta=0.0001e10)
     self.assertTrue(kerbin.has_atmosphere)
     self.assertAlmostEqual(70000, kerbin.atmosphere_depth)
     self.assertTrue(kerbin.has_atmospheric_oxygen)
     pos = (0, 0, kerbin.equatorial_radius)
     self.assertAlmostEqual(310,
                            kerbin.temperature_at(pos,
                                                  kerbin.reference_frame),
                            delta=50)
     pos = (0, 0, kerbin.equatorial_radius + 10000)
     self.assertAlmostEqual(220,
                            kerbin.temperature_at(pos,
                                                  kerbin.reference_frame),
                            delta=50)
     self.assertAlmostEqual(1.139923, kerbin.density_at(0), places=3)
     self.assertAlmostEqual(0.281931, kerbin.density_at(10000), places=3)
     self.assertAlmostEqual(0.015128, kerbin.density_at(25000), places=3)
     self.assertAlmostEqual(17930, kerbin.pressure_at(10000), delta=100)
     self.assertEqual([
         'Badlands', 'Deserts', 'Grasslands', 'Highlands', 'Ice Caps',
         'Mountains', 'Northern Ice Shelf', 'Shores', 'Southern Ice Shelf',
         'Tundra', 'Water'
     ], sorted(kerbin.biomes))
     self.assertEqual('Water', kerbin.biome_at(0, 0))
     self.assertEqual('Grasslands', kerbin.biome_at(42, 4))
     self.assertEqual(18000, kerbin.flying_high_altitude_threshold)
     self.assertEqual(250000, kerbin.space_high_altitude_threshold)
예제 #2
0
    def check_directions(self, flight):
        """ Check flight.direction against flight.heading and flight.pitch """
        direction = vector(flight.direction)
        up_direction = (1, 0, 0)
        north_direction = (0, 1, 0)
        self.assertAlmostEqual(1, norm(direction))

        # Check vessel direction vector agrees with pitch angle
        pitch = 90 - rad2deg(math.acos(dot(up_direction, direction)))
        self.assertAlmostEqual(pitch, flight.pitch, delta=2)

        # Check vessel direction vector agrees with heading angle
        up_component = dot(direction, up_direction) * vector(up_direction)
        north_component = normalize(vector(direction) - up_component)
        self.assertDegreesAlmostEqual(
            rad2deg(math.acos(dot(north_component, north_direction))),
            flight.heading, delta=1)
예제 #3
0
파일: test_body.py 프로젝트: Loran425/krpc
 def test_kerbin(self):
     kerbin = self.space_center.bodies['Kerbin']
     self.assertEqual('Kerbin', kerbin.name)
     self.assertAlmostEqual(5.2915158e22, kerbin.mass, delta=0.0001e22)
     self.assertAlmostEqual(3.5316000e12,
                            kerbin.gravitational_parameter, delta=0.0001e12)
     self.assertAlmostEqual(9.81, kerbin.surface_gravity, places=2)
     self.assertAlmostEqual(21549.425, kerbin.rotational_period, delta=0.1)
     self.assertAlmostEqual((2*3.14159) / 21549.425,
                            kerbin.rotational_speed, delta=0.1)
     self.assertAlmostEqual(math.pi/2, kerbin.initial_rotation, delta=0.1)
     self.assertDegreesAlmostEqual(
         rad2deg(kerbin.initial_rotation +
                 (self.space_center.ut * kerbin.rotational_speed)),
         rad2deg(kerbin.rotation_angle), delta=0.1)
     self.assertAlmostEqual(600000, kerbin.equatorial_radius)
     self.assertAlmostEqual(8.4159e7,
                            kerbin.sphere_of_influence, delta=0.0001e7)
     self.assertAlmostEqual(1.36e10, kerbin.orbit.apoapsis, delta=0.0001e10)
     self.assertAlmostEqual(1.36e10,
                            kerbin.orbit.periapsis, delta=0.0001e10)
     self.assertTrue(kerbin.has_atmosphere)
     self.assertAlmostEqual(70000, kerbin.atmosphere_depth)
     self.assertTrue(kerbin.has_atmospheric_oxygen)
     pos = (0, 0, kerbin.equatorial_radius)
     self.assertAlmostEqual(
         310, kerbin.temperature_at(pos, kerbin.reference_frame), delta=50)
     pos = (0, 0, kerbin.equatorial_radius + 10000)
     self.assertAlmostEqual(
         220, kerbin.temperature_at(pos, kerbin.reference_frame), delta=50)
     self.assertAlmostEqual(1.139923, kerbin.density_at(0), places=3)
     self.assertAlmostEqual(0.281931, kerbin.density_at(10000), places=3)
     self.assertAlmostEqual(0.015128, kerbin.density_at(25000), places=3)
     self.assertAlmostEqual(17930, kerbin.pressure_at(10000), delta=100)
     self.assertEqual(['Badlands', 'Deserts', 'Grasslands', 'Highlands',
                       'Ice Caps', 'Mountains', 'Northern Ice Shelf',
                       'Shores', 'Southern Ice Shelf', 'Tundra', 'Water'],
                      sorted(kerbin.biomes))
     self.assertEqual('Water', kerbin.biome_at(0, 0))
     self.assertEqual('Grasslands', kerbin.biome_at(42, 4))
     self.assertEqual(18000, kerbin.flying_high_altitude_threshold)
     self.assertEqual(250000, kerbin.space_high_altitude_threshold)
예제 #4
0
 def test_rad2deg(self):
     self.assertAlmostEqual(0, 0)
     self.assertAlmostEqual(90, rad2deg(math.pi / 2))
     self.assertAlmostEqual(180, rad2deg(math.pi))
     self.assertAlmostEqual(360, rad2deg(2 * math.pi))
예제 #5
0
 def test_rad2deg(self):
     self.assertAlmostEqual(0, 0)
     self.assertAlmostEqual(90, rad2deg(math.pi/2))
     self.assertAlmostEqual(180, rad2deg(math.pi))
     self.assertAlmostEqual(360, rad2deg(2*math.pi))