def test_angles(): arc = ConstructionArc(radius=1, start_angle=30, end_angle=60) assert tuple(arc.angles(2)) == (30, 60) assert tuple(arc.angles(3)) == (30, 45, 60) arc.start_angle = 180 arc.end_angle = 0 assert tuple(arc.angles(2)) == (180, 0) assert tuple(arc.angles(3)) == (180, 270, 0) arc.start_angle = -90 arc.end_angle = -180 assert tuple(arc.angles(2)) == (270, 180) assert tuple(arc.angles(4)) == (270, 0, 90, 180)
def from_arc(cls, arc: ConstructionArc, start_width: float, end_width: float, segments: int = 64) -> 'CurvedTrace': """ Create curved trace from an arc. Args: arc: :class:`~ezdxf.math.ConstructionArc` object start_width: start width end_width: end width segments: count of segments for full circle (360 degree) approximation, partial arcs have proportional less segments, but at least 3 Raises: ValueError: if arc.radius <= 0 """ if arc.radius <= 0: raise ValueError(f'Invalid radius: {arc.radius}.') curve_trace = cls() count = max(math.ceil(arc.angle_span / 360.0 * segments), 3) + 1 center = Vec2(arc.center) for point, width in zip(arc.vertices(arc.angles(count)), linspace(start_width, end_width, count)): curve_trace._append(point, point - center, width) return curve_trace