Beispiel #1
0
def test_permutations(context_with_points: Tuple[Context, Sequence[Point]],
                      index: int) -> None:
    context, points = context_with_points

    result = context.points_box(points)

    assert result == context.points_box(permute(points, index))
def test_permutations(context_with_segments: Tuple[Context, Sequence[Segment]],
                      index: int) -> None:
    context, segments = context_with_segments

    result = context.segments_box(segments)

    assert result == context.segments_box(permute(segments, index))
def test_permutations(context_with_contours: Tuple[Context, Sequence[Contour]],
                      index: int) -> None:
    context, contours = context_with_contours

    result = context.contours_box(contours)

    assert result == context.contours_box(permute(contours, index))
Beispiel #4
0
def test_permutations(first_point: BoundPoint, second_point: BoundPoint,
                      third_point: BoundPoint) -> None:
    result = sign(first_point, second_point, third_point)

    points = [first_point, second_point, third_point]
    assert all(
        sign(*permute(points, permutation)) == (
            result if is_even_permutation(permutation) else -result)
        for permutation in permutations(range(3)))
Beispiel #5
0
def test_permutations(points_triplet: PortedPointsTriplet) -> None:
    first_point, second_point, third_point = points_triplet

    result = sign(first_point, second_point, third_point)

    points = [first_point, second_point, third_point]
    assert all(
        sign(*permute(points, permutation)) == (
            result if is_even_permutation(permutation) else -result)
        for permutation in permutations(range(3)))
Beispiel #6
0
def test_endpoints_permutations(context_with_points_quadruplet: Tuple[
    Context, PointsQuadruplet], first_index: int, second_index: int) -> None:
    context, points_quadruplet = context_with_points_quadruplet
    first_start, first_end, second_start, second_end = points_quadruplet

    result = context.dot_product(first_start, first_end, second_start,
                                 second_end)

    result_sign = to_sign(result)
    first_endpoints = first_start, first_end
    second_endpoints = second_start, second_end
    assert (to_sign(
        context.dot_product(
            *permute(first_endpoints, first_index),
            *permute(
                second_endpoints,
                second_index))) == (result_sign if equivalence(
                    is_even_permutation(first_index, len(first_endpoints)),
                    is_even_permutation(second_index, len(second_endpoints)))
                                    else -result_sign))
def test_permutations(context_with_points_triplet: Tuple[Context,
                                                         PointsTriplet],
                      index: int) -> None:
    context, points_triplet = context_with_points_triplet
    vertex, first_ray_point, second_ray_point = points_triplet

    result = context.angle_orientation(vertex, first_ray_point,
                                       second_ray_point)

    assert (context.angle_orientation(*permute(points_triplet, index)) is
            (result if is_even_permutation(index, len(points_triplet)) else
             Orientation(-result)))
def test_permutations(context_with_points_quadruplet: Tuple[Context,
                                                            PointsQuadruplet],
                      index: int) -> None:
    context, points_quadruplet = context_with_points_quadruplet
    point, first_point, second_point, third_point = points_quadruplet

    result = context.locate_point_in_point_point_point_circle(
            point, first_point, second_point, third_point)

    assert (context.locate_point_in_point_point_point_circle(
            *permute(points_quadruplet, index))
            is (result
                if is_even_permutation(index, len(points_quadruplet))
                else to_opposite_location(result)))