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 test_0_length(self): cp = CP(Vector2D(1, 0), 0, Angle(10)) calculated = cp.calculate(Angle(1)) self.assertEqual(1, calculated.x)
def test_backward_upsidedown(self): cp = CP(Vector2D(1, 0), 12, Angle(10)) calculated = cp.calculate(Angle(-175)) self.assertEqual(-8, calculated.x)
def test_backward_upsidedown_stalled(self): cp = CP(Vector2D(1, 0), 12, Angle(10)) calculated = cp.calculate(Angle(-130)) self.assertEqual(-6.5, calculated.x)
def test_down_vertical(self): cp = CP(Vector2D(1, 0), 12, Angle(10)) calculated = cp.calculate(Angle(-90)) self.assertEqual(-5, calculated.x)
def test_down_stalled(self): cp = CP(Vector2D(1, 0), 12, Angle(10)) calculated = cp.calculate(Angle(-50)) self.assertEqual(-3.5, calculated.x)
def test_just_past_vertical(self): cp = CP(Vector2D(1, 0), 12, Angle(10)) calculated = cp.calculate(Angle(91)) self.assertEqual(-5.0375, calculated.x)
def test_normal(self): cp = CP(Vector2D(1, 0), 12, Angle(10)) calculated = cp.calculate(Angle(1)) self.assertEqual(-2, calculated.x)
def test_null_angle(self): cp = CP(Vector2D(1, 0), 12, None) calculated = cp.calculate(Angle(1)) self.assertEqual(1, calculated.x)