def test_arc_from_2p_angle_simple(): p1 = (2, 1) p2 = (0, 3) angle = 90 arc = ConstructionArc.from_2p_angle(start_point=p1, end_point=p2, angle=angle) assert arc.center == (0, 1) assert isclose(arc.radius, 2) assert isclose(arc.start_angle, 0, abs_tol=1e-12) assert isclose(arc.end_angle, 90) arc = ConstructionArc.from_2p_angle(start_point=p2, end_point=p1, angle=angle) assert arc.center == (2, 3) assert isclose(arc.radius, 2) assert isclose(arc.start_angle, 180) assert isclose(arc.end_angle, -90)
def test_arc_from_2p_angle_complex(): p1 = (-15.73335, 10.98719) p2 = (-12.67722, 8.76554) angle = 55.247230 arc = ConstructionArc.from_2p_angle(start_point=p1, end_point=p2, angle=angle) arc_result = ConstructionArc( center=(-12.08260, 12.79635), radius=4.07443, start_angle=-153.638906, end_angle=-98.391676, ) assert arc.center.isclose(arc_result.center, abs_tol=1e-5) assert isclose(arc.radius, arc_result.radius, abs_tol=1e-5) assert isclose(arc.start_angle, arc_result.start_angle, abs_tol=1e-4) assert isclose(arc.end_angle, arc_result.end_angle, abs_tol=1e-4)
axis=start_point_wcs - def_point_wcs, point=end_point_wcs) start_point_ucs = ucs.from_wcs(start_point_wcs) end_point_ucs = ucs.from_wcs(end_point_wcs) def_point_ucs = Vec3(0, 0) # origin of UCS # create arc in the xy-plane of the UCS arc = ConstructionArc.from_3p(start_point_ucs, end_point_ucs, def_point_ucs) arc.add_to_layout(modelspace, ucs, dxfattribs={'color': 1}) # red arc arc = ConstructionArc.from_3p(end_point_ucs, start_point_ucs, def_point_ucs) arc.add_to_layout(modelspace, ucs, dxfattribs={'color': 2}) # yellow arc p1 = Vec3(0, -18) p2 = Vec3(0, +18) arc = ConstructionArc.from_2p_angle(p1, p2, 90) arc.add_to_layout(modelspace, dxfattribs={'color': 1}) arc = ConstructionArc.from_2p_angle(p1, p2, 90, ccw=False) arc.add_to_layout(modelspace, dxfattribs={'color': 2}) p1 = Vec3(20, -18) p2 = Vec3(20, +18) arc = ConstructionArc.from_2p_radius(p1, p2, 100) arc.add_to_layout(modelspace, dxfattribs={'color': 1}) arc = ConstructionArc.from_2p_radius(p1, p2, 100, ccw=False) arc.add_to_layout(modelspace, dxfattribs={'color': 2}) arc = ConstructionArc.from_2p_radius(p1, p2, 100, center_is_left=False) arc.add_to_layout(modelspace, dxfattribs={'color': 3})