Exemplo n.º 1
0
def contains_point() -> None:
    polygon = Polygon(points[0: len(points) - 1])
    polygon.draw(canvas)
    if polygon.does_contain(points[-1]):
        messagebox.showinfo("Result", "Point is INSIDE polygon")
    else:
        messagebox.showinfo("Result", "Point is OUTSIDE polygon")
Exemplo n.º 2
0
def test_does_contain() -> None:
    """
        Tests if Polygon class method does_contain works correctly.
        Two common and one edge case.
    """
    polygon = Polygon([
        Point(1, 1),
        Point(5, 6),
        Point(5, 3),
        Point(2, 5),
        Point(4, 8),
        Point(2, 3),
        Point(4, 1),
        Point(3, 4)
    ])

    point_in = Point(4, 4)
    point_out = Point(0, 0)
    point_edge = Point(5, 3)

    assert polygon.does_contain(point_in)
    assert not polygon.does_contain(point_out)
    assert polygon.does_contain(point_edge)