Beispiel #1
0
def to_bound_multisegment(raw: RawMultisegment) -> BoundSegmentsList:
    result = []
    for segment in raw.segments:
        result.append(
            BoundSegment(BoundPoint(segment.start.x, segment.start.y),
                         BoundPoint(segment.end.x, segment.end.y)))
    return result
Beispiel #2
0
def test_triangle_inequality(first_point: BoundPoint, second_point: BoundPoint,
                             third_point: BoundPoint) -> None:
    straight_distance = first_point.distance_to(second_point)
    workaround_distance = (first_point.distance_to(third_point) +
                           third_point.distance_to(second_point))

    assert (straight_distance <= workaround_distance
            or math.isclose(straight_distance, workaround_distance))
Beispiel #3
0
def to_bound_multipoint(raw: RawMultipoint) -> BoundPointsList:
    result = []
    for point in raw.points:
        result.append(BoundPoint(point.x, point.y))
    return result
Beispiel #4
0
def test_basic(x: float, y: float) -> None:
    bound, ported = BoundPoint(x, y), PortedPoint(x, y)

    assert are_bound_ported_points_equal(bound, ported)
Beispiel #5
0
def test_symmetry(first_point: BoundPoint, second_point: BoundPoint) -> None:
    assert (first_point.distance_to(second_point) == second_point.distance_to(
        first_point))
Beispiel #6
0
def test_sign(first_point: BoundPoint, second_point: BoundPoint) -> None:
    assert equivalence(first_point != second_point,
                       first_point.distance_to(second_point) > 0)
Beispiel #7
0
def test_self(point: BoundPoint) -> None:
    assert not point.distance_to(point)
Beispiel #8
0
def raw_segment_to_segments_pair(raw: RawSegment) -> BoundPortedSegmentsPair:
    return (BoundSegment(BoundPoint(raw.start.x, raw.start.y),
                         BoundPoint(raw.end.x, raw.end.y)),
            PortedSegment(PortedPoint(raw.start.x, raw.start.y),
                          PortedPoint(raw.end.x, raw.end.y)))
Beispiel #9
0
def test_basic(x: float, y: float) -> None:
    result = BoundPoint(x, y)

    assert result.x == x
    assert result.y == y
Beispiel #10
0
def to_bound_with_ported_points_pair(x: float, y: float
                                     ) -> BoundPortedPointsPair:
    return BoundPoint(x, y), PortedPoint(x, y)