def test_angles_to_ocs_deg(): ucs = UCS.from_x_axis_and_point_in_xy(origin=(1, 2, 3), axis=(2, 3, 4), point=(3, 2, 5)) angles = [15, 30, 90] expected = [ucs.to_ocs_angle_deg(a) for a in angles] result = ucs.angles_to_ocs_deg(angles) assert result == expected
def test_ucs_direction_to_ocs_direction(): ucs = UCS.from_x_axis_and_point_in_xy(origin=(1, 2, 3), axis=(2, 3, 4), point=(3, 2, 5)) assert ucs.is_cartesian is True expected = (-3.350073025395333, 2.9626020192591795, 6) assert ucs.ucs_direction_to_ocs_direction(Vector(2, 4, 6)).isclose(expected)
def test_ocs_angles_to_ocs_deg(): ucs = UCS.from_x_axis_and_point_in_xy(origin=(1, 2, 3), axis=(2, 3, 4), point=(3, 2, 5)) angles = [15, 30, 90] # tests only the actual state - as it is - not granted results are correct expected = [-128.92976741554182, -113.92976741554183, -53.929767415541825] result = ucs.ocs_angles_to_ocs_deg(angles, extrusion=Vector(1, 2, 3)) assert result == expected
def test_spatial_arc_from_3p(): start_point_wcs = Vector(0, 1, 0) end_point_wcs = Vector(1, 0, 0) def_point_wcs = Vector(0, 0, 1) ucs = UCS.from_x_axis_and_point_in_xy(origin=def_point_wcs, axis=end_point_wcs - def_point_wcs, point=start_point_wcs) start_point_ucs = ucs.from_wcs(start_point_wcs) end_point_ucs = ucs.from_wcs(end_point_wcs) def_point_ucs = Vector(0, 0) arc = ConstructionArc.from_3p(start_point_ucs, end_point_ucs, def_point_ucs) dwg = ezdxf.new('R12') msp = dwg.modelspace() dxf_arc = arc.add_to_layout(msp, ucs) assert dxf_arc.dxftype() == 'ARC' assert isclose(dxf_arc.dxf.radius, 0.81649658, abs_tol=1e-9) assert isclose(dxf_arc.dxf.start_angle, 330) assert isclose(dxf_arc.dxf.end_angle, 210) assert dxf_arc.dxf.extrusion.isclose((0.57735027, 0.57735027, 0.57735027), abs_tol=1e-9)
# create a 2D arcs in xy-plane delta = 30 for count in range(12): modelspace.add_arc(center=(0, 0), radius=10 + count, start_angle=count * delta, end_angle=(count + 1) * delta) # create a 3D arc from 3 points in WCS start_point_wcs = Vec3(3, 0, 0) end_point_wcs = Vec3(0, 3, 0) def_point_wcs = Vec3(0, 0, 3) # create UCS ucs = UCS.from_x_axis_and_point_in_xy(origin=def_point_wcs, 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)
def test_to_ocs_angle_deg(): ucs = UCS.from_x_axis_and_point_in_xy(origin=(1, 2, 3), axis=(2, 3, 4), point=(3, 2, 5)) expected = 120.077450607124 assert isclose(ucs.to_ocs_angle_deg(45), expected)