コード例 #1
0
def center_position(ai_center_diameter, ai_pd1, ai_pd2, ai_pd3, ai_pd4, ai_optional_additional_axis_length):
  """ compute the four axis center
  """
  # inter-axis length
  l12 = (ai_pd1+ai_pd2)/2.0 + ai_optional_additional_axis_length
  l23 = (ai_pd2+ai_pd3)/2.0 + ai_optional_additional_axis_length
  l34 = (ai_pd3+ai_pd4)/2.0 + ai_optional_additional_axis_length
  l41 = (ai_pd4+ai_pd1)/2.0 + ai_optional_additional_axis_length
  # l13 arbitrary
  l13_min = max(l12, l23, l34, l41)
  l13_max = min(l12+l23, l34+l41)
  l13 = (l13_min+l13_max)/2.0
  print("l13: min {:0.3f}  max {:0.3f} l13 {:0.3f}".format(l13_min, l13_max, l13))
  # c1
  c1x = 0.0
  c1y = 0.0
  # c3
  c3x = c1x + 0.0
  c3y = c1y + l13
  # c2
  # law of cosines: BAC = math.acos((b**2+c**2-a**2)/(2*b*c))
  a213 = math.acos((l12**2+l13**2-l23**2)/(2*l12*l13))
  c2a = math.pi/2-a213
  c2x = c1x + l12*math.cos(c2a)
  c2y = c1y + l12*math.sin(c2a)
  # c4
  a314 = math.acos((l41**2+l13**2-l34**2)/(2*l41*l13))
  c4a = math.pi/2+a314
  c4x = c1x + l41*math.cos(c4a)
  c4y = c1y + l41*math.sin(c4a)
  # info_txt
  info_txt = """
  center coordiantes:
  c1: x {:0.3f}  y {:0.3f}
  c2: x {:0.3f}  y {:0.3f}
  c3: x {:0.3f}  y {:0.3f}
  c4: x {:0.3f}  y {:0.3f}
  """.format(c1x, c1y, c2x, c2y, c3x, c3y, c4x, c4y)
  print("{:s}".format(info_txt))
  ### dxf
  # plank outline 
  smooth_radius = 40
  center_plank_A = [
    (c1x,               c1y-smooth_radius,  smooth_radius),
    (c2x+smooth_radius, c2y,                smooth_radius),
    (c3x,               c3y+smooth_radius,  smooth_radius),
    (c4x-smooth_radius, c4y,                smooth_radius),
    (c1x,               c1y-smooth_radius,  0)]
  center_plank_B = cnc25d_api.cnc_cut_outline(center_plank_A, "center_plank_A")
  # figure
  center_figure = [
    center_plank_B,
    (c1x, c1y, ai_center_diameter/2.0),
    (c2x, c2y, ai_center_diameter/2.0),
    (c3x, c3y, ai_center_diameter/2.0),
    (c4x, c4y, ai_center_diameter/2.0)]
  if(not sim):
    cnc25d_api.generate_output_file(center_figure, "test_output/jh01_zahnrad_center_{:0.2f}.dxf".format(ai_optional_additional_axis_length), 10.0, "hello")
コード例 #2
0
ファイル: bug_dxf_arc.py プロジェクト: Python3pkg/Cnc25D
#curve_c_list.append(((101.71723019438343, 96.1956604093075, 1.0460946476969504), (105.50385415484162, 104.45333383437541, 1.2221709170309811), (108.85611827975636, 117.26186725898447, 1.3982471863650119)))
#curve_c_list.append(((105.24093171976327, 120.51699585849344, 3.4188615491393364), (92.8529717988778, 115.84423947162142, 3.594937818473369), (85.03634475640621, 111.21519712013114, 3.7710140878073997)))

curve_figure = []
for i in range(len(curve_c_list)):
    curve_figure.append(
        cnc25d_api.smooth_outline_c_curve(curve_c_list[i], radian_epsilon, 0,
                                          "bug_dxf_arc"))

arc_outline1 = ((145.16105345972858, 67.29241085339282),
                (141.6992073306823, 67.71248119850708, 138.22285460617988,
                 67.98781635950473), (135.08404356534385, 68.0977769789459,
                                      131.94350769783776, 68.06227271427393),
                (129.50007306219516, 67.9282460984374, 127.06410626967998,
                 67.69500429649403), (124.9839019702478, 67.40296694443323,
                                      122.91986242240063, 67.01274074426519))
arc_outline2 = ((145, 67), (138.22285460617988, 67.98781635950473),
                (135.08404356534385, 68.0977769789459, 131.94350769783776,
                 68.06227271427393), (127, 67))
arc_outline3 = ((138, 68), (131.94350769783776, 68.06227271427393),
                (129.50007306219516, 67.9282460984374, 127.06410626967998,
                 67.69500429649403), (123, 67))  # here is the bug
arc_figure = []
arc_figure.append(arc_outline3)

#dxf_figure = line_arc_figure
#dxf_figure = curve_figure
dxf_figure = arc_figure
cnc25d_api.generate_output_file(dxf_figure, "test_output/bug_dxf_arc.dxf",
                                10.0, "hello")
コード例 #3
0
def center_position(ai_center_diameter, ai_pd1, ai_pd2, ai_pd3, ai_pd4,
                    ai_optional_additional_axis_length):
    """ compute the four axis center
  """
    # inter-axis length
    l12 = (ai_pd1 + ai_pd2) / 2.0 + ai_optional_additional_axis_length
    l23 = (ai_pd2 + ai_pd3) / 2.0 + ai_optional_additional_axis_length
    l34 = (ai_pd3 + ai_pd4) / 2.0 + ai_optional_additional_axis_length
    l41 = (ai_pd4 + ai_pd1) / 2.0 + ai_optional_additional_axis_length
    # l13 arbitrary
    l13_min = max(l12, l23, l34, l41)
    l13_max = min(l12 + l23, l34 + l41)
    l13 = (l13_min + l13_max) / 2.0
    print("l13: min {:0.3f}  max {:0.3f} l13 {:0.3f}".format(
        l13_min, l13_max, l13))
    # c1
    c1x = 0.0
    c1y = 0.0
    # c3
    c3x = c1x + 0.0
    c3y = c1y + l13
    # c2
    # law of cosines: BAC = math.acos((b**2+c**2-a**2)/(2*b*c))
    a213 = math.acos((l12**2 + l13**2 - l23**2) / (2 * l12 * l13))
    c2a = math.pi / 2 - a213
    c2x = c1x + l12 * math.cos(c2a)
    c2y = c1y + l12 * math.sin(c2a)
    # c4
    a314 = math.acos((l41**2 + l13**2 - l34**2) / (2 * l41 * l13))
    c4a = math.pi / 2 + a314
    c4x = c1x + l41 * math.cos(c4a)
    c4y = c1y + l41 * math.sin(c4a)
    # info_txt
    info_txt = """
  center coordiantes:
  c1: x {:0.3f}  y {:0.3f}
  c2: x {:0.3f}  y {:0.3f}
  c3: x {:0.3f}  y {:0.3f}
  c4: x {:0.3f}  y {:0.3f}
  """.format(c1x, c1y, c2x, c2y, c3x, c3y, c4x, c4y)
    print("{:s}".format(info_txt))
    ### dxf
    # plank outline
    smooth_radius = 40
    center_plank_A = [(c1x, c1y - smooth_radius, smooth_radius),
                      (c2x + smooth_radius, c2y, smooth_radius),
                      (c3x, c3y + smooth_radius, smooth_radius),
                      (c4x - smooth_radius, c4y, smooth_radius),
                      (c1x, c1y - smooth_radius, 0)]
    center_plank_B = cnc25d_api.cnc_cut_outline(center_plank_A,
                                                "center_plank_A")
    # figure
    center_figure = [
        center_plank_B, (c1x, c1y, ai_center_diameter / 2.0),
        (c2x, c2y, ai_center_diameter / 2.0),
        (c3x, c3y, ai_center_diameter / 2.0),
        (c4x, c4y, ai_center_diameter / 2.0)
    ]
    if (not sim):
        cnc25d_api.generate_output_file(
            center_figure,
            "test_output/jh01_zahnrad_center_{:0.2f}.dxf".format(
                ai_optional_additional_axis_length), 10.0, "hello")
コード例 #4
0
ファイル: bug_dxf_arc.py プロジェクト: charlyoleg/Cnc25D
  line_arc_figure.append(one_outline)
# no bug with line_arc_figure

curve_c_list = []
#curve_c_list.append(((159.98151030973634, 2.4323566793799003, 2.581103508182059), (148.21981244670462, 8.511720678292365, 2.7571797775160896), (139.54941918366882, 11.223172702078283, 2.933256046850122)))
#curve_c_list.append(((138.83335837113063, 18.03603624395383, 0.41777611697899175), (146.75054016395106, 22.49091265889753, 0.5938523863130225), (156.99124586112094, 30.88282245801178, 0.7699286556470533)))
#curve_c_list.append(((155.97981508135746, 35.641230158140374, 2.7905430184213778), (143.21116768796654, 39.14235097807352, 2.9666192877554103), (134.16650074547297, 39.991875146271866, 3.142695557089441)))
#curve_c_list.append(((132.04961360140717, 46.50698385962108, 0.6272156272183107), (138.86756508881277, 52.510585189520754, 0.8032918965523415), (147.13971064079655, 62.84827406176453, 0.979368165886374)))
curve_c_list.append(((145.16105345972858, 67.29241085339282, 2.9999825286606985), (131.94350769783776, 68.06227271427393, 3.1760587979947292), (122.91986242240063, 67.01274074426519, 3.35213506732876)))
#curve_c_list.append(((119.49466707295448, 72.94535311535454, 0.8366551374576296), (124.91541105878456, 80.23529317361815, 1.0127314067916622), (130.85746401080218, 92.06695450953949, 1.188807676125693)))
#curve_c_list.append(((127.99805724189297, 96.00259028953901, 3.2094220389000174), (114.90928328611828, 94.00754653384051, 3.385498308234048), (106.30103627652832, 91.10482800892721, 3.5615745775680807)))
#curve_c_list.append(((101.71723019438343, 96.1956604093075, 1.0460946476969504), (105.50385415484162, 104.45333383437541, 1.2221709170309811), (108.85611827975636, 117.26186725898447, 1.3982471863650119)))
#curve_c_list.append(((105.24093171976327, 120.51699585849344, 3.4188615491393364), (92.8529717988778, 115.84423947162142, 3.594937818473369), (85.03634475640621, 111.21519712013114, 3.7710140878073997)))

curve_figure = []
for i in range(len(curve_c_list)):
  curve_figure.append(cnc25d_api.smooth_outline_c_curve(curve_c_list[i], radian_epsilon, 0, "bug_dxf_arc"))

arc_outline1 = ((145.16105345972858, 67.29241085339282), (141.6992073306823, 67.71248119850708, 138.22285460617988, 67.98781635950473), (135.08404356534385, 68.0977769789459, 131.94350769783776, 68.06227271427393), (129.50007306219516, 67.9282460984374, 127.06410626967998, 67.69500429649403), (124.9839019702478, 67.40296694443323, 122.91986242240063, 67.01274074426519))
arc_outline2 = ((145, 67), (138.22285460617988, 67.98781635950473), (135.08404356534385, 68.0977769789459, 131.94350769783776, 68.06227271427393), (127, 67))
arc_outline3 = ((138, 68), (131.94350769783776, 68.06227271427393), (129.50007306219516, 67.9282460984374, 127.06410626967998, 67.69500429649403), (123, 67)) # here is the bug
arc_figure = []
arc_figure.append(arc_outline3)

#dxf_figure = line_arc_figure
#dxf_figure = curve_figure
dxf_figure = arc_figure
cnc25d_api.generate_output_file(dxf_figure, "test_output/bug_dxf_arc.dxf", 10.0, "hello")