Beispiel #1
0
def test_counter_clockwise():
    points = (0, 0), (100, 0), (50, 50)
    assert orientation(*points) == -orientation(*reversed(points))
    assert not clockwise(*points)
    assert counter_clockwise(*points)
    assert clockwise(*reversed(points))
    assert not counter_clockwise(*reversed(points))
Beispiel #2
0
def test_orientation_2():
    triangles = (
        ((3, 4), (5, 6), (9, 5), True),
        ((5, 6), (9, 5), (12, 8), False),
        ((9, 5), (12, 8), (5, 11), False),
        ((12, 8), (5, 11), (3, 4), False),
    )
    for *points, is_clockwise in triangles:
        # = triangle
        assert clockwise(*points) is is_clockwise
        assert counter_clockwise(*points) is not is_clockwise
        assert clockwise(*reversed(points)) is not is_clockwise
        assert counter_clockwise(*reversed(points)) is is_clockwise
Beispiel #3
0
def test_orientation():
    points = (5, 0), (6, 4), (4, 5)
    assert counter_clockwise(*points)
    assert clockwise(*reversed(points))