Exemplo n.º 1
0
def test_merge_none():
    pts = [
        np.array([1, 1]),
        np.array([0, 1]),
    ]
    angles = [
        math.pi / 4,
        math.pi / 2,
    ]
    seg1 = Segment(pts[0], pts[1], angles[0], angles[1])
    seg1.merge(None)
    np.testing.assert_allclose(seg1.p1, pts[0])
    np.testing.assert_allclose(seg1.p2, pts[1])
    assert seg1.theta1 == approx(angles[0])
    assert seg1.theta2 == approx(angles[1])
Exemplo n.º 2
0
def test_merge_before():
    pts = [
        np.array([1, 1]),
        np.array([0, 1]),
        np.array([-1, 1]),
    ]
    angles = [
        math.pi / 4,
        math.pi / 2,
        3 * math.pi / 4,
    ]
    seg1 = Segment(pts[0], pts[1], angles[0], angles[1])
    seg2 = Segment(pts[1], pts[2], angles[1], angles[2])
    seg2.merge(seg1)
    np.testing.assert_allclose(seg2.p1, pts[0])
    np.testing.assert_allclose(seg2.p2, pts[2])
    assert seg2.theta1 == approx(angles[0])
    assert seg2.theta2 == approx(angles[2])