示例#1
0
from compas.geometry import offset_polyline
from compas.utilities import linspace

from compas_plotters import GeometryPlotter

controlpoints = [
    Point(0, 0, 0),
    Point(4, 2.5, 0),
    Point(6, -2.5, 0),
    Point(10, 0, 0)
]
controlpoly = Polyline(controlpoints)

curve = Bezier(controlpoints)
poly = Polyline(curve.locus())
poly1 = Polyline(offset_polyline(poly, +0.15))
poly2 = Polyline(offset_polyline(poly, -0.15))

points = [curve.point(t) for t in linspace(0, 1, 20)]
tangents = [curve.tangent(t) for t in linspace(0, 1, 20)]
normals = [Vector(0, 0, 1).cross(t) for t in tangents]

# ==============================================================================
# Visualization
# ==============================================================================

plotter = GeometryPlotter(figsize=(16, 9))

plotter.add(controlpoly,
            linestyle='dotted',
            linewidth=1.0,
示例#2
0
def test_variable_offset_on_colinear_polyline(polyline, distance, normal, tol, output_polyline):
    output_polyline = [v for v in output_polyline]
    assert allclose(offset_polyline(polyline, distance, normal, tol), output_polyline)
示例#3
0
def test_variable_offset_on_colinear_polyline(polyline, distance, normal, tol,
                                              output_polyline):
    output_polyline = [pytest.approx(v) for v in output_polyline]
    assert offset_polyline(polyline, distance, normal, tol) == output_polyline
示例#4
0
def test_offset_polyline_equals_offset_line(polyline, distance, normal, tol):
    output_line = [v for v in offset_line(polyline, distance, normal)]
    assert allclose(offset_polyline(polyline, distance, normal, tol), output_line)
示例#5
0
def test_offset_polyline_equals_offset_line(polyline, distance, normal, tol):
    output_line = [
        pytest.approx(v) for v in offset_line(polyline, distance, normal)
    ]
    assert offset_polyline(polyline, distance, normal, tol) == output_line