Exemplo n.º 1
0
def test_spline_interpolated_profiles():
    p1 = circle(12, radius=2, elevation=0, close=True)
    p2 = circle(12, radius=3, elevation=2, close=True)
    p3 = circle(12, radius=1, elevation=4, close=True)
    p4 = circle(12, radius=2, elevation=6, close=True)
    profiles = list(spline_interpolated_profiles([p1, p2, p3, p4], subdivide=4))
    assert len(profiles) == 13  # 3*4 + 1
Exemplo n.º 2
0
def test_from_profiles_splines():
    p1 = circle(12, radius=2, elevation=0, close=True)
    p2 = circle(12, radius=3, elevation=2, close=True)
    p3 = circle(12, radius=1, elevation=4, close=True)
    p4 = circle(12, radius=2, elevation=6, close=True)
    mesh = from_profiles_spline([p1, p2, p3, p4], subdivide=4, caps=True)
    assert len(mesh.vertices) == 156  # 12 (circle) * 13 (profiles)
    assert len(mesh.faces) == 146  # 12 (circle) * 12 + 2
Exemplo n.º 3
0
def polylines(filename):
    with r12writer(filename) as r12:
        r12.add_polyline_2d(circle(8), color=1, closed=False)
        r12.add_polyline_2d(
            translate(circle(8), vec=(3, 0)), color=3, closed=True
        )
        r12.add_polyline_2d(
            [(0, 4), (4, 4, 1), (8, 4, 0, 0.2, 0.000001), (12, 4)],
            format="xybse",
            start_width=0.1,
            end_width=0.1,
            color=5,
        )
    print(f'saved as "{filename}".')
Exemplo n.º 4
0
def test_ngons_to_triangles():
    open_square = square()
    r = list(ngon_to_triangles(open_square))
    assert len(r) == 4
    center = r[0][2]
    assert center == (0.5, 0.5, 0)

    closed_square = list(circle(4, elevation=2, close=True))
    assert len(closed_square) == 5
    r = list(ngon_to_triangles(closed_square))
    assert len(r) == 4
    center = r[0][2]
    assert center.isclose((0, 0, 2))

    # also subdivide triangles
    r = list(ngon_to_triangles([(0, 0), (1, 0), (1, 1)]))
    assert len(r) == 3
Exemplo n.º 5
0
def test_close_circle():
    assert len(list(circle(8, close=True))) == 9
    assert len(list(close_polygon(circle(8, close=True)))) == 9
    assert len(list(close_polygon(circle(8, close=False)))) == 9
Exemplo n.º 6
0
def test_circle_closed():
    c = list(circle(8, close=True))
    assert len(c) == 9
Exemplo n.º 7
0
def test_circle_open():
    c = list(circle(8))
    assert len(c) == 8
Exemplo n.º 8
0
def test_subdivide_ngons():
    hexagon = list(circle(6))
    result = list(subdivide_ngons([hexagon]))
    assert len(result) == 6
Exemplo n.º 9
0
def test_rect_inside_circle(rect):
    c = circle(16, 3)
    result = clip_polygon_2d(c, rect, ccw_check=False)
    assert len(result) == 4
    for v in rect:
        assert v in result
Exemplo n.º 10
0
def test_rect_outside_circle(rect):
    c = circle(16, 0.7)
    result = clip_polygon_2d(c, rect, ccw_check=False)
    assert len(result) == 16
    for v in c:
        assert v in result
Exemplo n.º 11
0
def test_circle_inside_rect(rect):
    c = Vec2.list(circle(16, 0.7))
    result = clip_polygon_2d(rect, c, ccw_check=False)
    assert len(result) == 16
    for v in c:
        assert v in result
Exemplo n.º 12
0
def test_circle_outside_rect(rect):
    c = circle(16, 3)
    result = clip_polygon_2d(rect, c, ccw_check=False)
    assert len(result) == 4
    for v in rect:
        assert v in result