Ejemplo n.º 1
0
def test_rotations(contour_with_point: Tuple[Contour, Point]) -> None:
    contour, point = contour_with_point

    result = point_in_contour(point, contour)

    assert all(result is point_in_contour(point, rotated)
               for rotated in contour_rotations(contour))
Ejemplo n.º 2
0
def test_reversals(contour_with_point: Tuple[Contour, Point]) -> None:
    contour, point = contour_with_point

    result = point_in_contour(point, contour)

    assert result is point_in_contour(point, reverse_contour(contour))
    assert result is point_in_contour(reverse_point_coordinates(point),
                                      reverse_contour_coordinates(contour))
Ejemplo n.º 3
0
def test_connection_with_point_in_contour(
        contour_with_segment: Tuple[Contour, Segment]) -> None:
    contour, segment = contour_with_segment

    result = segment_in_contour(segment, contour)

    assert implication(
        result is Relation.DISJOINT,
        point_in_contour(segment.start, contour) is point_in_contour(
            segment.end, contour) is Location.EXTERIOR)
Ejemplo n.º 4
0
def test_basic(contour_with_point: Tuple[Contour, Point]) -> None:
    contour, point = contour_with_point

    result = point_in_contour(point, contour)

    assert isinstance(result, Location)
    assert result in LINEAR_LOCATIONS
Ejemplo n.º 5
0
def test_connection_with_point_in_contour(
        contours_pair: Tuple[Contour, Contour]) -> None:
    left_contour, right_contour = contours_pair

    assert implication(
        contour_in_contour(left_contour, right_contour)
        in (Relation.EQUAL, Relation.COMPONENT),
        all(
            point_in_contour(vertex, right_contour) is Location.BOUNDARY
            for vertex in left_contour.vertices))
Ejemplo n.º 6
0
def test_self(contour: Contour) -> None:
    assert all(
        point_in_contour(vertex, contour) is Location.BOUNDARY
        for vertex in contour.vertices)