def __init__(self, name, relative_pos=Vector2D(0, 0), chord_length=1, angle=Angle(0), area=1, lift_curve=None, drag_curve=None, atmosphere=Atmosphere()): self._point = Point(relative_pos) self.name = name self.angle = angle self.area = area self._atmosphere = atmosphere self.lift_curve = lift_curve self.drag_curve = drag_curve if lift_curve is not None: stall_angle = lift_curve.stall_angle() else: stall_angle = None self.cp = CP(relative_pos, chord_length, stall_angle) self.velocity = Vector2D(0, 0) self.current_cp = Vector2D(0, 0)
def __init__(self): self._flying_objects = {} self._stationary_objects = {} self._tethers = {} self._current_key = 0 self.atmosphere = Atmosphere() self.space = pymunk.Space() self.preview_forces = []
def __init__(self, position, velocity): atmosphere = Atmosphere() state = State(position, velocity, Angle(0), 0) Airplane.__init__(self, state, self._mass(), self._mass_moment_of_inertia(), atmosphere) wing_lift_curve = lift.Linear(6.98, 0.29, 5.5) wing_drag_curve = drag.LiftingLine(6.98, 0.0305, 0.75) self._wing = Surface("wing", Vector2D(0, 0), 0, Angle(2.4), 510.97, wing_lift_curve, wing_drag_curve, atmosphere) stab_lift_curve = lift.LiftingLine(3.62) stab_drag_curve = drag.LiftingLine(3.62, efficiency_factor=0.6) self._horizontal_stabilizer = Surface("stabilizer", Vector2D(-33, 0), 0, Angle(0), 136, stab_lift_curve, stab_drag_curve, atmosphere) fusilage_drag_curve = drag.Parasitic(0.27) # 747 cabin = ~19x6 meters self._fusilage = Surface("fusilage", self.cg(), 0, Angle(0), 118, None, fusilage_drag_curve, atmosphere) self._surfaces = [] self._surfaces.append(self._wing) self._surfaces.append(self._horizontal_stabilizer) self._surfaces.append(self._fusilage) # don't have yaw forces (or a 3rd axis) to put engines out on wings # so they all go at cg self._engines = [] self._engines.append(Engine("engine 1", self.cg(), Angle(0), 0, 275000)) self._engines.append(Engine("engine 2", self.cg(), Angle(0), 0, 275000)) self._engines.append(Engine("engine 3", self.cg(), Angle(0), 0, 275000)) self._engines.append(Engine("engine 4", self.cg(), Angle(0), 0, 275000))
joystick = None if pygame.joystick.get_count() > 0: joystick = pygame.joystick.Joystick(0) print("Using joystick " + joystick.get_name()) joystick.init() else: print("Using keyboard") projector = display.Projector(Vector2D(SCREEN_WIDTH, SCREEN_HEIGHT)) debug_draw = display.DebugDraw(screen, projector) pygame.font.init() font = pygame.font.SysFont('Comic Sans MS', 30) # create rocket and add to the list of sprites atmosphere = Atmosphere() rocket = planes.FalconHeavy(Vector2D(0, 35), Vector2D(0, 0), atmosphere) rocket_sprite = RocketSprite(rocket, "examples/images/Falcon_Heavy.png", projector) all_sprites = pygame.sprite.Group() all_sprites.add(rocket_sprite) projector.set_resolution(rocket_sprite.rect.width, 70) projector.center(rocket.position()) projector.center(rocket.position()) simulator = Simulator() simulator.register_flying_object(rocket) clouds = pygame.sprite.Group()
from flight.kites.box_kite import BoxKite from physics.vector_2d import Vector2D from flight.simulator import Simulator from flight.atmosphere import Atmosphere kite = BoxKite(.7, .35, .175, Atmosphere(), initial_pos=Vector2D(0, 1000)) simulator = Simulator() simulator.register_flying_object(kite) t = 1 / 40.0 print("start") for i in range(0, 2000): simulator.step(t) print("done")
def get_cessna_wing(self): wing_lift_curve = lift.LiftingLine(7.37) wing_drag_curve = drag.LiftingLine(7.37, 0.027, 0.75) return Surface("cessna 172 wing", Vector2D(0, 0), 0, Angle(0), 16.2, wing_lift_curve, wing_drag_curve, Atmosphere())
def get_boeing_wing(self): wing_lift_curve = lift.Linear(6.98, 0.29, 5.5) wing_drag_curve = drag.LiftingLine(6.98, 0.0305, 0.75) return Surface("boeing wing", Vector2D(0, 0), 0, Angle(2.4), 510.97, wing_lift_curve, wing_drag_curve, Atmosphere())
def get_flat_plate(self): wing_lift_curve = lift.PlateEmpirical(0) wing_drag_curve = drag.FlatPlate(0) return Surface("plate", Vector2D(0, 0), 0, Angle(0), 10, wing_lift_curve, wing_drag_curve, Atmosphere())
def get_surface(self, relative_degrees): return Surface("test", Vector2D(0, 0), 0, Angle(relative_degrees), 10, None, None, Atmosphere())
def test_really_high(self): density = Atmosphere().get_air_density(100000) self.assertEqual(0.00001846, density)
def test_low(self): density = Atmosphere().get_air_density(500) self.assertEqual(1.225, density)
def test_almost_next(self): density = Atmosphere().get_air_density(29999) self.assertEqual(0.04008, density)
def test_exact_match(self): density = Atmosphere().get_air_density(5000) self.assertEqual(0.7364, density)
def test_really_low(self): density = Atmosphere().get_air_density(-10000) self.assertEqual(1.347, density)