Example #1
0
def test_as_bspline():
    spiral = EulerSpiral(2.0)
    spline = spiral.bspline(5, 10)
    assert spline.degree == 3
    assert spline.max_t == 5
    results = spline.approximate(10)
    for expected, result in zip(expected_points, results):
        assert is_close_points(Vector(expected), result)
Example #2
0
def euler_spiral(count: int, length: float = 1, curvature: float = 1, elevation: float = 0) -> Iterable[Vector]:
    """
    Create polygon vertices for an `euler spiral <https://en.wikipedia.org/wiki/Euler_spiral>`_ of a given `length` and
    radius of curvature. This is a parametric curve, which always starts
    at the origin ``(0, 0)``.

    Args:
        count: count of polygon vertices
        length: length of curve in drawing units
        curvature: radius of curvature
        elevation: z-axis for all vertices

    Returns:
        vertices as :class:`~ezdxf.math.Vector` objects

    """
    spiral = EulerSpiral(curvature=curvature)
    for vertex in spiral.approximate(length, count - 1):
        yield vertex.replace(z=elevation)
Example #3
0
def euler_spiral(count: int,
                 length: float = 1,
                 curvature: float = 1,
                 elevation: float = 0) -> Iterable[Vector]:
    """
    Create polygon vertices for an euler spiral of a given length and
    radius of curvature. This is a parametric curve, which always starts
    at the origin.

    Args:
        count: count of polygon vertices
        length: length of curve in drawing units
        curvature: radius of curvature
        elevation: z-axis for all vertices

    Returns: yields Vector() objects

    """
    spiral = EulerSpiral(curvature=curvature)
    for vertex in spiral.approximate(length, count - 1):
        yield vertex.replace(z=elevation)
Example #4
0
def test_circle_midpoint():
    spiral = EulerSpiral(2.0)
    m = spiral.circle_midpoint(2.0)
    assert is_close_points(m, (0.9917242992178723, 2.082593218533209, 0))
Example #5
0
def test_distance():
    spiral = EulerSpiral(2.0)
    assert isclose(spiral.distance(10), 0.4)
Example #6
0
def test_tangent():
    spiral = EulerSpiral(2.0)
    assert isclose(spiral.tangent(1).angle, 0.125)
Example #7
0
def test_radius():
    spiral = EulerSpiral(2.0)
    assert isclose(spiral.radius(1), 4.)
    assert isclose(spiral.radius(0), 0.)
Example #8
0
def test_approximate():
    spiral = EulerSpiral(2.0)
    results = spiral.approximate(5, 10)
    for expected, result in zip(expected_points, results):
        assert is_close_points(Vector(expected), result)