Exemplo n.º 1
0
def test_relative_bearing5():
    s = Mock(
        pos=Point3(),
        angle=pi
    )
    a = ai.ShipAI(s)
    approx_eq(
        abs(a.relative_bearing(Point3(0, 0, 1))),
        pi
    )
Exemplo n.º 2
0
def test_relative_bearing():
    """Straight ahead means an angle of 0.0"""
    s = Mock(
        pos=Point3(),
        angle=0.0
    )
    a = ai.ShipAI(s)
    eq_(
        a.relative_bearing(Point3(0, 0, 1)),
        0.0
    )
Exemplo n.º 3
0
def test_relative_bearing3():
    """Positive angles are to port."""
    s = Mock(
        pos=Point3(),
        angle=0.0
    )
    a = ai.ShipAI(s)
    approx_eq(
        a.relative_bearing(Point3(1, 0, 1)),
        pi / 4
    )
Exemplo n.º 4
0
def test_relative_bearing4():
    """Behind and to the right of us is to starboard."""
    s = Mock(
        pos=Point3(),
        angle=0.0
    )
    a = ai.ShipAI(s)
    approx_eq(
        a.relative_bearing(Point3(-1, 0, -1)),
        pi * -0.75
    )
Exemplo n.º 5
0
def test_relative_bearing2():
    """The ship's own angle is taken into account."""
    s = Mock(
        pos=Point3(),
        angle=0.5
    )
    a = ai.ShipAI(s)
    eq_(
        a.relative_bearing(Point3(0, 0, 1)),
        -0.5
    )