コード例 #1
0
def test_reversals(context_with_point_and_factors
                   : Tuple[Context, Point, Scalar, Scalar]) -> None:
    context, point, factor_x, factor_y = context_with_point_and_factors

    result = context.scale_point(point, factor_x, factor_y)

    assert reverse_point_coordinates(result) == context.scale_point(
            reverse_point_coordinates(point), factor_y, factor_x)
コード例 #2
0
def test_reversals(
    context_with_point_and_steps: Tuple[Context, Point, Scalar,
                                        Scalar]) -> None:
    context, point, step_x, step_y = context_with_point_and_steps

    result = context.translate_point(point, step_x, step_y)

    assert reverse_point_coordinates(result) == context.translate_point(
        reverse_point_coordinates(point), step_y, step_x)
コード例 #3
0
def test_reversals(context_with_contour: Tuple[Context, Contour]) -> None:
    context, contour = context_with_contour

    result = context.region_centroid(contour)

    assert result == context.region_centroid(reverse_contour(contour))
    assert reverse_point_coordinates(result) == context.region_centroid(
        reverse_contour_coordinates(contour))
コード例 #4
0
def test_reversals(region_with_point: Tuple[Region, Point]) -> None:
    region, point = region_with_point

    result = point_in_region(point, region)

    assert result is point_in_region(point, reverse_contour(region))
    assert result is point_in_region(reverse_point_coordinates(point),
                                     reverse_contour_coordinates(region))
コード例 #5
0
def test_reversals(segment_with_point: Tuple[Segment, Point]) -> None:
    segment, point = segment_with_point

    result = point_in_segment(point, segment)

    assert result is point_in_segment(point, reverse_segment(segment))
    assert result is point_in_segment(reverse_point_coordinates(point),
                                      reverse_segment_coordinates(segment))
コード例 #6
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))
コード例 #7
0
def test_reversals(context_with_polygon: Tuple[Context, Polygon]) -> None:
    context, polygon = context_with_polygon

    result = context.polygon_centroid(polygon)

    assert (result == context.polygon_centroid(reverse_polygon_border(polygon))
            == context.polygon_centroid(reverse_polygon_holes(polygon)))
    assert (reverse_point_coordinates(result) == context.polygon_centroid(
        reverse_polygon_coordinates(polygon)))
コード例 #8
0
def test_reversals(
        context_with_polygons: Tuple[Context, Multipolygon]) -> None:
    context, multipolygon = context_with_polygons

    result = context.multipolygon_centroid(multipolygon)

    assert result == context.multipolygon_centroid(
        reverse_multipolygon(multipolygon))
    assert reverse_point_coordinates(result) == context.multipolygon_centroid(
        reverse_multipolygon_coordinates(multipolygon))
コード例 #9
0
def test_reversals(context_with_multisegment: Tuple[Context, Multisegment]
                   ) -> None:
    context, multisegment = context_with_multisegment

    result = context.multisegment_centroid(multisegment)

    assert result == context.multisegment_centroid(reverse_multisegment(
            multisegment))
    assert result == reverse_point_coordinates(context.multisegment_centroid(
            reverse_multisegment_coordinates(multisegment)))
コード例 #10
0
def test_reversed_coordinates(segments: List[Segment]) -> None:
    result = segments_intersections(segments)

    reversed_result = segments_intersections(
        reverse_segments_coordinates(segments))
    assert result == {
        ids_pair: tuple(
            sorted(
                reverse_point_coordinates(endpoint) for endpoint in endpoints))
        for ids_pair, endpoints in reversed_result.items()
    }
コード例 #11
0
def test_reversals(polygon_with_point: Tuple[Polygon, Point]) -> None:
    polygon, point = polygon_with_point

    result = point_in_polygon(point, polygon)

    assert result is point_in_polygon(point, reverse_polygon_border(polygon))
    assert result is point_in_polygon(point, reverse_polygon_holes(polygon))
    assert result is point_in_polygon(point,
                                      reverse_polygon_holes_contours(polygon))
    assert result is point_in_polygon(reverse_point_coordinates(point),
                                      reverse_polygon_coordinates(polygon))
コード例 #12
0
def test_reversals(
        context_with_segment_and_point: Tuple[Context, Segment,
                                              Point]) -> None:
    context, segment, point = context_with_segment_and_point

    result = context.segment_contains_point(segment, point)

    assert result is context.segment_contains_point(reverse_segment(segment),
                                                    point)
    assert result is context.segment_contains_point(
        reverse_segment_coordinates(segment), reverse_point_coordinates(point))
コード例 #13
0
def test_reversals(context_with_segment_and_point
                   : Tuple[Context, Segment, Point]) -> None:
    context, segment, point = context_with_segment_and_point

    result = context.segment_point_squared_distance(segment, point)

    assert result == context.segment_point_squared_distance(
            reverse_segment(segment), point)
    assert result == context.segment_point_squared_distance(
            reverse_segment_coordinates(segment),
            reverse_point_coordinates(point))
コード例 #14
0
def test_reversals(multisegment_with_point: Tuple[Multisegment, Point]
                   ) -> None:
    multisegment, point = multisegment_with_point

    result = point_in_multisegment(point, multisegment)

    assert result is point_in_multisegment(point,
                                           reverse_multisegment(multisegment))
    assert result is point_in_multisegment(
            reverse_point_coordinates(point),
            reverse_multisegment_coordinates(multisegment))
コード例 #15
0
def test_reversals(multiregion_with_point: Tuple[Multiregion, Point]) -> None:
    multiregion, point = multiregion_with_point

    result = point_in_multiregion(point, multiregion)

    assert result is point_in_multiregion(point,
                                          reverse_multiregion(multiregion))
    assert result is point_in_multiregion(
        point, reverse_multiregion_regions(multiregion))
    assert result is point_in_multiregion(
        reverse_point_coordinates(point),
        reverse_multiregion_coordinates(multiregion))
コード例 #16
0
def test_reversals(
    context_with_segments_pair: Tuple[Context, Tuple[Segment,
                                                     Segment]]) -> None:
    context, (first, second) = context_with_segments_pair

    result = context.segments_intersection(first, second)

    assert (result == context.segments_intersection(
        reverse_segment(first), second) == context.segments_intersection(
            first, reverse_segment(second)) == context.segments_intersection(
                reverse_segment(first), reverse_segment(second)))
    assert reverse_point_coordinates(result) == context.segments_intersection(
        reverse_segment_coordinates(first),
        reverse_segment_coordinates(second))
コード例 #17
0
def test_reversed_coordinates(contour: Contour) -> None:
    result = edges_intersect(contour)

    assert result is edges_intersect(
        [reverse_point_coordinates(vertex) for vertex in contour])