(完整版)vb圆弧插补程序
vb圆弧插补程序(可编辑修改word版)

Private Sub Command1_Click()Const pi = 3.14159265Picture1.ForeColor = vbBlackPicture1.DrawWidth = 2Picture1.Line (50, 500)-(50, 5500)Picture1.Line (50, 5500)-(6500, 5500)Picture1.Line (80, 600)-(50, 500)Picture1.Line (20, 600)-(50, 500)Picture1.Line (6400, 5450)-(6500, 5500) Picture1.Line (6400, 5550)-(6500, 5500) Picture1.ForeColor = vbRedPicture1.DrawWidth = 3If Int(Text1) = 0 ThenPicture1.Circle (50, 5500), Sqr(Int(Text1) *Int(Text1) + Int(Text2) * Int(Text2)) * 400, , Atn(Int(Text4) / Int(Text3)), pi / 2ElsePicture1.Circle (50, 5500), Sqr(Int(Text1) *Int(Text1) + Int(Text2) * Int(Text2)) * 400, , Atn(Int(Text4) / Int(Text3)), Atn(Int(Text2) /Int(Text1))End IfEnd SubPrivate Sub Command2_Click()Dim k, m, j, l, n, F(20) As Integerm = 0l = Text1.Textk = Text2.TextF(m) = 0Picture1.ForeColor = vbGreenPicture1.DrawWidth = 3j = Abs(Int(Text1) - Int(Text3)) + Abs(Int(Text2) - Int(Text4))Form1.CurrentX = 200Form1.CurrentY = 200 Print "初始:进给方向" & "F(m)=0" & " X0=" & Int(Text1) & " Y0=" & Int(Text2) & " ∑= " & jFor n = 1 To jIf F(m) >= 0 And j > 0 Thenm = m + 1k = k - 1F(m) = F(m - 1) - 2 * Abs(k + 1) + 1Picture1.Line (50 + 400 * l, 5500 - k * 400)-(50 + 400 * l, 5500 - (k + 1) * 400)Form1.CurrentX = 200Form1.CurrentY = 200 + m * 300Print "第" & m & "步" & " -△y F(" & m & ")= " & F(m) & " " & "x=" & l & " " & "y="; k & " ∑=" & j - nElsel = l + 1m = m + 1Picture1.Line (50 + 400 * l, 5500 - k * 400)-(50 + 400 * (l - 1), 5500 - k * 400)F(m) = F(m - 1) + 2 * Abs(l - 1) + 1Form1.CurrentX = 200Form1.CurrentY = 200 + m * 300Print "第" & m & "步" & " +△x F(" & m & ")= " & F(m) & " " & "x="; l & " " & "y="; k & " ∑=" & j - nEnd IfNext nEnd SubPrivate Sub Command3_Click()Text1.Text = ""Text3.Text = ""End SubPrivate Sub Command4_Click()EndEnd SubPrivate Sub Command1_Click()Picture1.ForeColor = vbBlackPicture1.DrawWidth = 2Picture1.Line (7500, 8500)-(7500, 500)Picture1.Line (7500, 500)-(500, 500)Picture1.Line (7500, 8500)-(7400, 8400)Picture1.Line (7500, 8500)-(7600, 8400)Picture1.Line (500, 500)-(600, 600)Picture1.Line (500, 500)-(600, 400)Picture1.ForeColor = vbRedPicture1.DrawWidth = 5Picture1.Line (7500, 500)-(7500 + 400 *Int(Text3), 500 - 400 * Int(Text4))End SubPrivate Sub Command2_Click()Form1.ClsDim k, m, j, l, n, F(20) As Integerm = 0l = 0k = 0F(m) = 0Picture1.ForeColor = vbGreenPicture1.DrawWidth = 3j = Abs(Int(Text3)) + Abs(Int(Text4))Form1.CurrentX = 200Form1.CurrentY = 200Print "初始:进给方向" & "F(m)=0" & " Xe=" & Int(Text3) & " Ye=" & Int(Text4) & " ∑= " & jFor n = 1 To jIf F(m) >= 0 And j > 0 Thenm = m + 1l = l - 1F(m) = F(m - 1) - Abs(Int(Text4))Picture1.Line (7500 + 400 * (l + 1), 500 - k * 400)-(7500 + 400 * (l), 500 - k * 400)Form1.CurrentX = 200Form1.CurrentY = 200 + m * 300Print "第" & m & "步" & " △x F(" & m & ")= " & F(m) & " " & "x=" & l & " " & "y="; k & " ∑=" & j - nElsek = k - 1m = m + 1Picture1.Line (7500 + 400 * l, 500 - (k + 1) * 400)-(7500 + 400 * l, 500 - k * 400)F(m) = F(m - 1) + Abs(Int(Text3))Form1.CurrentX = 200Form1.CurrentY = 200 + m * 300Print "第" & m & "步" & " △y F(" & m & ")= " & F(m) & " " & "x="; l & " " & "y="; k & " ∑=" & j - nEnd IfNext nEnd SubPrivate Sub Command3_Click()Text1.Text = ""Text2.Text = ""Picture1.ClsForm1.ClsEnd SubPrivate Sub Command4_Click()EndEnd SubPrivate Sub Form_Load()End SubPrivate Sub Command1_Click()Const pi = 3.14159265Picture1.ForeColor = vbBlackPicture1.DrawWidth = 2Picture1.Line (50, 500)-(50, 5500)Picture1.Line (50, 5500)-(6500, 5500)Picture1.Line (80, 600)-(50, 500)Picture1.Line (20, 600)-(50, 500)Picture1.Line (6400, 5450)-(6500, 5500) Picture1.Line (6400, 5550)-(6500, 5500) Picture1.ForeColor = vbRedPicture1.DrawWidth = 3Picture1.Line (50, 5500)-(50 + 400 * Int(Text3), 5500 - 400 * Int(Text4))End SubPrivate Sub Command2_Click()Dim k, m, j, l, n, F, G As Integerl = 0 k = 0 F = 0 G = 0Picture1.ForeColor = vbGreenPicture1.DrawWidth = 3n = Int(Text5)j = 2 ^ nm = 2 ^ nForm1.CurrentX = 200Form1.CurrentY = 200Print "累加次数" & "F= F + int (text3)" & "+△X " & " G=G +int(text4)" & " +△Y "; ∑ = " & j"Print " n " & " 0 " & " 0 " & " 0 " & " 0 " & jFor n = 1 To mF = F + Int(Text3)G = G + Int(Text4) If F >= m And G >= m Thenl = l + 1 k = k + 1Picture1.Line (50 + 400 * (l - 1), 5500 - (k - 1) * 400)-(50 + 400 * (l), 5500 - k * 400)F = F - mG = G - mPrint " "; n & " " & F & " " & 1 & " " & G & "j - 1" & 1 & " " & ElseIf F >= m And G < m Thenl = l + 1F = F - mPrint " "; n & " " & F & " " & 1 & " " & G & "j - 1" & 0 & " " &Picture1.Line (50 + 400 * (l - 1), 5500 - k * 400)-(50 + 400 * (l), 5500 - k * 400)ElseIf F < m And G >= m Thenk = k + 1 G = G - mPicture1.Line (50 + 400 * l, 5500 - (k - 1) * 400)-(50 + 400 * (l), 5500 - k * 400)Print " "; n & " " & F & " " & 0 & " " & G & " " & 1 & " " & j - 1ElseIf F < m And G < m ThenPrint " "; n & " " & F & " " & 0 & " " & G & " " & 0 & " " & j - 1End Ifj = j - 1Next nEnd SubPrivate Sub Command3_Click()Text1.Text = ""Text2.Text = ""Picture1.ClsForm1.ClsEnd SubPrivate Sub Command4_Click()End End Sub。
圆弧插补指令编程

•%
小结
所有不同型号的数控车床、铣床都必须用到G00、G01、G02、 G03指令,这四个指令在所有数控系统中都通用。在数控车、铣床 自动编程中,任何平面、曲面加工的路径最后都是由直线、圆弧插 补组成。所以说,这四个指令是数控编程的最基本组成单元。
① 用绝对值编程时,圆弧终点坐标为圆弧终点在工件坐标系中的坐标值,用X、Z 表 示。当用增量值编程时,圆弧终点坐标为圆弧终点相对于圆弧起点的增量值,用U、W表示。
② 圆心坐标(I, K)为圆弧起点到圆弧中心点所作矢量分别在X、Z坐标轴方向上分矢 量(矢量方向指向圆心)。本系统I、K为增量值,并带有“±”号,当矢量的方向与坐标轴 的方向不一致时取“”号。
安全操作和注意事项
(1)选刀时,刀尖角一定要控制在40°以下,如果刀尖角过大,凹圆 弧将过切。
(2)装刀时,刀尖同工件中心高对齐,对刀前,先将工件端面车平。 (3)为保证精加工尺寸准确性,可分半精加工、精加工。 (4)由于暂不计刀尖圆弧半径,因此实际圆弧存有过切或欠切现象。
工件的参考程序
• O0304 (O0304); • G40G97G99M03S500T0101F
用G02、G03指令加工圆弧面时,要注意顺、逆方向及圆弧半径 和圆心坐标编程的不同之处。
通过实训项目的学习,了解数控车床对刀与工件坐标系之间的 关系;通过半精加工、精加工掌握如何控制工件尺寸。
数控机床操作入门
模块三 单一指令加工应用
圆弧插补指令g02g03

通过简单的图形 如图所示的 cd 段的连接方式。象这样的圆弧外形我们用什么指令来
设疑,引入新课。 加工呢?这就要用到今天我们所要学习的圆弧插补 G02/G03。
(多媒 体展 示图 形,
教师设疑)
三、讲授新课
讲授新课
一、格式。
(10 分钟)
在数控机床上运行该代码指令表现为刀具以走圆弧迹的方式从 现处的位置移动至所指定的位置。移动的速度由进给速度 F 指令指
1
圆弧插补指令
使 用 图形 设 疑 引导学生学习
复习提问: 1、G00 指令的使用方法 2、G01 指令的使用方法
引入新课:圆弧连接应 怎样加工呢?
知识拓展
提出新课任务
新课讲解:介绍圆弧指令格 式及其含义
学生 :练习使用圆弧指令编程 教师 :补充总结并评价
多媒体事例示范,规 范使用指令
教学方式方法与 时间分配
走 CD 段圆弧轨迹
N70 G1 Y-28 F150
走 DE 段直线轨迹
N80 X55
走 EF 段直线轨迹
N90 G3 X48 Y35 I-7 J0 F100
走 FG 段圆弧轨迹
N100 G1 Y43 F150
走 GH 段直线轨迹
N120 X-73
走 HL 段直线轨迹
N130 G0 Z50
Z 轴提刀至高于表面 50 毫米
检查记录
巩固练习
教学内容
2
组织教学
(2 分钟)
1、 师生互相问候。 2、 检查学生出勤,填写考查薄,注意学生精神面貌,并整顿学 生的课堂秩序。 3、 检查学生用具 :笔、尺、本是否齐全。
4、 讲授本节课的内容及布置各项任务。
复习旧课
一、复习旧课
圆弧插补指令应用-圆弧面零件编程.

圆弧插补指令应用圆弧面零件编程圆弧面零件编程加工是学习数控车床编程技术的重要一环,也是学习其它回转体类零件加工的基础。
通过本项目的学习,要掌握如下知识,顺时针圆弧插补、逆时针圆弧插补方向的判断和G02、G03圆弧插补指令及终点坐标+半径格式的应用;仿形车削复合循环指令G73及其应用;刀尖半径补偿指令G40、G41、G42及应用;凸圆弧零件加工工艺制定及循环参数选择;完成成形面类零件编程加工及其尺寸控制。
一、零件图二、数控车床编程指令插补的概念根据给定的进给速度和给定轮廓线形的要求,在轮廓的已知点之间,确定一些中间点的方法,称为插补方法或插补原理。
编程指令(一)圆弧插补指令G02、G03G02——顺时针圆弧插补G03——逆时针圆弧插补1.指令功能:使刀具按给定进给速度沿圆弧方向进行切削加工。
2.圆弧的顺、逆方向的判断沿垂直于圆弧所在平面的坐标轴的正方向向负方向看去,刀具相对于工件的转动方向是顺时针方向为G02,逆时针方向为G03。
3.圆弧加工终点坐标+圆弧半径(或圆心坐标)指令格式G02(G03)X_Z_R_ F_G02(G03)X_ Z_ I_ K_ F_(二)径向(端面) 粗车复合循环指令G72该指令适用于圆柱棒料粗车阶梯轴(或法兰盘)的外圆或内孔,需切除较多余量时的情况。
与轴向粗车复合循环的区别仅在于切削方向平行于X轴。
[ FANUC 0i ] 系统径向(端面)粗车复合循环指令格式:G72 W(△d) R(e);G72 P(ns) Q(nf) U(△u) W(△w) F(△f) S(△s) T(t);N(ns)……;……;.N(nf) ……;(三)仿形粗车(闭环车削)复合循环指令G73该指令用于零件毛坯已基本成型的铸件或锻件的加工,铸件或锻件的形状与零件轮廓相接近。
该功能在切削工件时刀具轨迹为一闭合回路,刀具逐渐进给�使封闭的切削回路逐渐向零件最终形状靠近,完成工件的加工。
[ FANUC 0i ] 系统仿形粗车(闭环车削)复合循环指令格式:G73 U(△i) W(△k) R(d);G73 P(ns) Q(nf) U(△u) W(△w) F(△f) S(△s) T(t);N(ns)……;……;N(nf) ……;(四)刀具补偿指令1.刀具补偿的目的数控车床是按车刀刀尖对刀的,因车刀的刀尖不可能绝对尖,总有一个小圆弧,所以对刀刀尖的位置是一个假想的刀尖A。
基于vb的直线插补与圆弧插补实验

主界面面板逐点比较圆弧插补程序如下:Private Sub Command1_Click()Xe = Val(Text1.Text)Ye = Val(Text2.Text)Picture1.Scale (-20, 20)-(20, -20)Picture1.ClsPicture1.Line (-20, 0)-(20, 0), vbBluePicture1.Line (19, 1)-(20, 0), vbbiuePicture1.Line -(19, -1), vbBluePicture1.Print "X"Picture1.Line (0, -20)-(0, 20), vbBluePicture1.Line (1, 19)-(0, 20), vbBluePicture1.Line -(-1, 19), vbBluePicture1.Print "Y"Picture1.Line (0, 0)-(Xe, Ye), vbBluePicture1.Print "("; Xe; ","; Ye; ")"If Text1.Text = none Or Text2.Text = none Then MsgBox "请输入加工终点坐标值。
"Text3.Text = 0Text4.Text = 0Text5.Text = 0End SubPrivate Sub Command2_Click()Dim sum As IntegerXe = Val(Text1.Text)Ye = Val(Text2.Text)Xm = Val(Text3.Text)Ym = Val(Text4.Text)m = Val(Text5.Text)sum = Xe * Ym - Xm * Ye'第一象限开始If Xe > 0 And Ye > 0 And sum >= 0 Then Picture1.Line (Xm, Ym)-(Xm + 1, Ym), vbRed: Text3.Text = Xm + 1If Xe > 0 And Ye > 0 And sum < 0 Then Picture1.Line (Xm, Ym)-(Xm, Ym + 1), vbRed: Text4.Text = Ym + 1If Abs(Xm) + Abs(Ym) >= Abs(Xe) + Abs(Ye) - 1 Then MsgBox "加工完毕!"'第二象限开始If Xe < 0 And Ye > 0 And sum >= 0 Then Picture1.Line (Xm, Ym)-(Xm, Ym + 1), vbRed: Text4.Text = Ym + 1If Xe < 0 And Ye > 0 And sum < 0 Then Picture1.Line (Xm, Ym)-(Xm - 1, Ym), vbRed: Text3.Text = Xm - 1If Abs(Xm) + Abs(Ym) >= Abs(Xe) + Abs(Ye) + 1 Then MsgBox "加工完毕!"'第三象限开始If Xe < 0 And Ye < 0 And sum >= 0 Then Picture1.Line (Xm, Ym)-(Xm - 1, Ym), vbRed:Text3.Text = Xm - 1If Xe < 0 And Ye < 0 And sum < 0 Then Picture1.Line (Xm, Ym)-(Xm, Ym - 1), vbRed: Text4.Text = Ym - 1If Abs(Xm) + Abs(Ym) >= Abs(Xe) + Abs(Ye) Then MsgBox "加工完毕!"'第四象限开始If Xe > 0 And Ye < 0 And sum >= 0 Then Picture1.Line (Xm, Ym)-(Xm, Ym - 1), vbRed: Text4.Text = Ym - 1If Xe > 0 And Ye < 0 And sum < 0 Then Picture1.Line (Xm, Ym)-(Xm + 1, Ym), vbRed: Text3.Text = Xm + 1If Abs(Xm) + Abs(Ym) >= Abs(Xe) + Abs(Ye) Then MsgBox "加工完毕!"Text5.Text = Abs(Val(Text3.Text)) + Abs(Val(Text4.Text))End SubPrivate Sub Command3_Click()Form2.HideForm1.ShowEnd Sub数字积分器法圆弧插补程序如下:Private Sub Command1_Click()Xe = Val(Text1.Text)Ye = Val(Text2.Text)Picture1.Scale (-20, 20)-(20, -20)Picture1.ClsPicture1.Line (-20, 0)-(20, 0), vbBluePicture1.Line (19, 1)-(20, 0), vbbiuePicture1.Line -(19, -1), vbBluePicture1.Print "X"Picture1.Line (0, -20)-(0, 20), vbBluePicture1.Line (1, 19)-(0, 20), vbBluePicture1.Line -(-1, 19), vbBluePicture1.Print "Y"Picture1.Line (0, 0)-(Xe, Ye), vbBluePicture1.Print "("; Xe; ","; Ye; ")"Text3.Text = 0Text4.Text = 0Text5.Text = 0Text6.Text = 0Text7.Text = 0End SubPrivate Sub Command2_Click()Xe = Val(Text1.Text)Ye = Val(Text2.Text)ax = V al(Text3.Text)ay = Val(Text4.Text)n = Val(Text7.Text)Xm = Val(Text5.Text)Ym = Val(Text6.Text)If Text1.Text = none Or Text2.Text = none Then MsgBox "请输入加工终点坐标值。
(完整版)圆弧插补

Fi<0
O Fi≥0
X Fi<0 Fi≥0
2、圆弧插补的象限处理
前面的圆弧插补(顺圆、逆圆)只限于第一象限,其他 情况如图所示: Y
O
X
代入偏差函数,得Pi+1点的偏差为: Fi+1 = Fi-2Xi + 1
当Fi<0时,向+Y方向进给一步。动点由Pi(Xi,Yi) 移动到 Pi+1(Xi,Yi +1)则新动点的坐标为 Yi+1=Yi +1
代入偏差函数,得Pi+1点的偏差为:
Fi+1 = Fi + 2Yi + 1
所以,第一象限逆时针圆弧插补加工时偏差加工的递推 公式为:
6 F5= -7 +Y F6=F5+2Y5+1 =0, X6=3,Y6=4 ∑=4
7 F6=0 -X F7=F6-2X6+1 = -5, X7=2,Y7=4 ∑=3 8 F7= -5 +Y F8=F7+2Y7+1 =4, X8=2,Y8=5 ∑=2
9 F8=4 -X F9=F8-2X8+1 = 1, X9=1,Y9=5 ∑=1
若P点在圆弧上,则有 (Xi2 +Yi2 ) — (Xo2 +Yo2) = 0,我们定义偏差函数Fi为 Fi = (Xi2 +Yi2 ) — (Xo2 +Yo2 )
Y
B(Xe,Ye)
Pi(Xi,Yi)
A(Xo,Yo) O
X
可见,若Fi=0,表示动点位于圆弧上;若Fi>0,表示动 点位于圆弧外;Fi<0,表示动点位于圆弧内。
(2)进给控制
把Fi=0和若Fi>0合在一起考虑,当Fi≥0时,向-X方向进 给一步;当Fi<0时,向+Y方向进给一步。
圆弧插补直线插补程序
else
Zf = 2;
end
Fm = Fm - 2 * XM + 1;
XM=XM-StepLength;
% XM = XM - 1;
else
if RNS == 2 || RNS ==5
Zf = 3;
else
Zf = 4;
end
Fm = Fm + 2 * YM + 1;
YM=YM+StepLength;
% YM = YM + 1;
end
end
% switch Zf
% case 1
% XM=XM+StepLength;
% case 2
% XM=XM-StepLength;
% case 3
% YM=YM+StepLength;
% case 4
% YM=YM-StepLength;
% end
x = [X0 XM];
else
Zf = 2;
end
Fm = Fm -Ye;
else
if Xoy == 1 || Xoy == 2
Zf = 3;
else
Zf = 4;
end
Fm = Fm + Xe;
end
switch Zf
case 1
XM=XM+Nxy;
case 2
XM=XM-Nxy;
case 3
YM=YM+Nxy;
case 4
(RNSS~=1)*(((Y0==0)*((X0>0)*3+(X0<0)*4))+((X0==0)*((Y0>0)*2+(Y0<0)*1)));
圆弧插补
圆弧插补G02、 G03指令刀具相对工件以 F指令的 进给速度从当前点(始点)向终点进行圆弧插补。
G02--------顺时针圆弧插补指令 G03--------逆时针圆弧插补指令 2、G02、G03的顺、逆方向 在判断顺、逆方向时,是从一个坐标轴的正 向往负向看,在另外两轴组成的平面中的转向。
G02
XZ平面: G18
XZR F
G03
G02
YZ平面: G19
YZR F
G03
圆弧插补
2、说明
(1)绝对编程时,X、Y、Z为圆弧终点坐标值; 增量编程时,X、Y、Z为终点相对始点的距离。
(2)R是圆弧半径,当圆弧所对的圆心角大于0 度小于180度时,R取正值;当圆心角大于等于180度 小于360度时,R取负值。
Y A
20
解: 1、圆弧终点: 点B(30,20) 2、顺、逆方向: 顺时针,G02 B 3、半径: R=15,圆心角为90度 4、指令:
O
15
G17 G02 X30 Y20 R15 F60 30 X 若说明是在铣床中加工,则指令:
G02 X30 Y20 R15 F60
圆弧插补
2、加工A-B-C圆弧的指令
圆弧插补
(1)数控车床的顺、逆方向
O G02
G03 Z
X
Y
O Z
G03 X
G02
数控车床只在XZ平面加工,从上往下看, 顺、逆方向正好与时钟方向相反。
圆弧插补
(2)数控铣床的顺、逆方向
Z
Y
G02
G03 O
X
圆弧插补
二、格式说明
1、程序段格式(R半径式):
XY平面: G17 G02 X
DDA直线插补和圆弧插补VB程序
ElseIf f * Di = 0 Then
If Di = 1 Then
f = f + 2 * y * Di + p
y = y + p
Else
f = f - 2 * x * Di + p
End If
f = f + Abs(xe - x0)
End If
obj.Line -(x, y), vbRed '画折线
n = n - 1
DoEvents
For i = 1 To 2000000 * p
'延时
Next i
Exit Sub
End If
pic.Cls '清屏
axis pic '画坐标轴
p = Val(Combo1.Text) '读取脉冲当量
cmdShow.Enabled = False
If Option1.Value Then '演示直线插补
Text1(2) <> "" And Text1(3) <> "" Then
x1 = Val(Text1(0)): y1 = Val(Text1(1))
x2 = Val(Text1(2)): y2 = Val(Text1(3))
Else
MsgBox "输入坐标不完整!"
Private Sub Text1_Change(Index As Integer)
If Abs(Val(Text1(Index).Text)) > 9 Then
VB软件 模拟逐点比较法逆圆弧插补的程序设计 程序
五、算法程序Private Sub Command1_Click()Picture1.ForeColor = vbBlackPicture1.DrawWidth = 2Picture1.Line (0, 4000)-(9000, 4000)Picture1.Line (4500, 0)-(4500, 8000)End SubPrivate Sub Command2_Click()Picture1.ForeColor = vbBluePicture1.DrawWidth = 2If Val(Text1.Text) * Val(Text1.Text) + Val(Text2.Text) * Val(Text2.Text) <> Val(Text3.Text) * Val(Text3.Text) + Val(Text4.Text) * Val(Text4.Text) Thenans = MsgBox("出错了,该象限所绘圆弧不以原点为圆心", 48, "提示信息")Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""ElseIf Option1.Value = True ThenIf Val(Text1) >= 0 And Val(Text2) >= 0 And Val(Text3) >= 0 And Val(Text4) >= 0 And Val(Text1) >= Val(Text3) Then If Int(Text2) = 0 ThenIf Int(Text3) = 0 ThenPicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , 0, 3.14159 / 2Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))ElsePicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , Atn(Val(Text2) / Val(Text1)), 3.14159 / 2Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))End IfElseIf Int(Text4) = 0 ThenPicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , 0, Atn(Val(Text2) / Val(Text1))ElsePicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , Atn(Val(Text2) / Val(Text1)), Atn(Val(Text4) / Val(Text3))Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))End IfElseans = MsgBox("坐标象限错误或预定圆弧将为顺时针", 48, "提示信息")Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""End IfElseIf Option4.Value = True ThenIf Val(Text1) >= 0 And Val(Text2) <= 0 And Val(Text3) >= 0 And Val(Text4) <= 0 And Val(Text1) <= Val(Text3) Then If Int(Text2) = 0 ThenIf Val(Text3) = 0 ThenPicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , 3 * 3.14159 / 2, 0Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))ElsePicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , Atn(Val(Text4) / Val(Text3)) + 3.14159 * 2, 0Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))End IfElseIf Val(Text3) <> 0 ThenPicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , Atn(Val(Text2) / Val(Text1)) + 3.14159 * 2, Atn(Val(Text4) / Val(Text3)) + 3.14159 * 2Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))ElsePicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , 3 * 3.14159 / 2, Atn(Val(Text2) / Val(Text1)) + 3.14159 * 2Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))End IfElseans = MsgBox("坐标象限错误或预定圆弧将为顺时针", 48, "提示信息")Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""End IfElseIf Option2.Value = True ThenIf Val(Text1) <= 0 And Val(Text2) >= 0 And Val(Text3) <= 0 And Val(Text4) >= 0 And Val(Text1) >= Val(Text3) Then If Int(Text2) = 0 ThenIf Val(Text3) = 0 ThenPicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , 3.14159 / 2, 3.14159Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))ElsePicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , Atn(Val(Text4) / Val(Text3)) + 3.14159, 3.14159Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))End IfElseIf Val(Text3) = 0 ThenPicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , 3.14159 / 2, Atn(Val(Text4) / Val(Text3)) + 3.14159Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))ElsePicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , Atn(Val(Text2) / Val(Text1)) + 3.14159, Atn(Val(Text4) / Val(Text3)) + 3.14159Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))End IfElseans = MsgBox("坐标象限错误或预定圆弧将为顺时针", 48, "提示信息")Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""End IfElseIf Option3.Value = True ThenIf Val(Text1) <= 0 And Val(Text2) <= 0 And Val(Text3) <= 0 And Val(Text4) <= 0 And Val(Text1) <= Val(Text3) ThenIf Int(Text1) = 0 ThenIf Int(Text4) = 0 ThenPicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , 3.14159, 3 * 3.14159 / 2Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))ElsePicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , Atn(Int(Text4) / Int(Text3)) + 3.14159, 3 * 3.14159 / 2Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))End IfElseIf Int(Text4) = 0 ThenPicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , 3.14159, Atn(Int(Text2) / Int(Text1)) + 3.14159Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))ElsePicture1.Circle (4500, 4000), Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2)) * Int(Text6), , Atn(Int(Text2) / Int(Text1)) + 3.14159, Atn(Int(Text4) / Int(Text3)) + 3.14159Text5.Text = Sqr(Val(Text1) * Val(Text1) + Val(Text2) * Val(Text2))End IfElseans = MsgBox("坐标象限错误或预定圆弧将为顺时针", 48, "提示信息")Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""End IfEnd IfEnd IfEnd SubPrivate Sub Command3_Click()If Val(Text1.Text) * Val(Text1.Text) + Val(Text2.Text) * Val(Text2.Text) <> Val(Text3.Text) * Val(Text3.Text) + Val(Text4.Text) * Val(Text4.Text) Thenans = MsgBox("出错了", 48, "提示信息")Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""ElseDim k, m, j, l, n, F(20) As IntegerDim a, b, c, d, e As Integerm = 0l = 0k = 0F(m) = 0a = Int(Text1)b = Int(Text2)c = Int(Text3)d = Int(Text4)e = Int(Text6)Picture1.ForeColor = vbGreenPicture1.DrawWidth = 3j = Abs(c - a) + Abs(d - b)Form1.CurrentX = 15000Form1.CurrentY = 200If Option1.Value = True ThenIf Val(Text1) >= 0 And Val(Text2) >= 0 And Val(Text3) >= 0 And Val(Text4) >= 0 And Option1.Value = True ThenPrint "初始:进给方向 " & "F(m)=0" & " X0=" & Int(Text1) & " Y0=" & Int(Text2) & " ∑ = " & jFor n = 1 To jIf F(m) >= 0 Thenm = m + 1k = k + 1F(m) = F(m - 1) - 2 * a + 1Picture1.Line (4500 + Int(Text1) * e - e * (k - 1), 4000 - Int(Text2) * e - l * e)-(4500 + Int(Text1) * e - e * k, 4000 - Int(Text2) * e - l * e)a = a - 1Form1.CurrentX = 15000Form1.CurrentY = 200 + n * 300Print "第" & m & "步" & " -△x F(" & m & ")= " & F(m) & " " & "x=" & a & " " & "y="; b & " ∑=" & j - nElsel = l + 1m = m + 1Picture1.Line (4500 + Int(Text1) * e - e * k, 4000 - Int(Text2) * e - (l - 1) * e)-(4500 + Int(Text1) * e - e * k, 4000 - Int(Text2) * e - l * e)F(m) = F(m - 1) + 2 * b + 1b = b + 1Form1.CurrentX = 15000Form1.CurrentY = 200 + n * 300Print "第" & m & "步" & " +△y F(" & m & ")= " & F(m) & " " & "x=" & a & " " & "y="; b & " ∑=" & j - nEnd IfNext nElseans = MsgBox("出错", 48, "提示信息")Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""Form1.ClsEnd IfElseIf Option4.Value = True ThenIf Val(Text1) >= 0 And Val(Text2) <= 0 And Val(Text3) >= 0 And Val(Text4) <= 0 And Option4.Value = True ThenPrint "初始:进给方向 " & "F(m)=0" & " X0=" & Int(Text1) & " Y0=" & Int(Text2) & " ∑ = " & jFor n = 1 To jIf F(m) >= 0 Thenm = m + 1l = l + 1F(m) = F(m - 1) - 2 * Abs(b) + 1Picture1.Line (4500 + Int(Text1) * e + e * k, 4000 - Int(Text2) * e - (l - 1) * e)-(4500 + Int(Text1) * e + e * k, 4000 - Int(Text2) * e - l * e)b = b + 1Form1.CurrentX = 15000Form1.CurrentY = 200 + n * 300Print "第" & m & "步" & " +△y F(" & m & ")= " & F(m) & " " & "x=" & a & " " & "y="; b & " ∑=" & j - nElsek = k + 1m = m + 1Picture1.Line (4500 + Int(Text1) * e + e * (k - 1), 4000 - Int(Text2) * e - l * e)-(4500 + Int(Text1) * e + e * k, 4000 - Int(Text2) * e - l * e)F(m) = F(m - 1) + 2 * Abs(a) + 1a = a + 1Form1.CurrentX = 15000Form1.CurrentY = 200 + n * 300Print "第" & m & "步" & " +△x F(" & m & ")= " & F(m) & " " & "x=" & a & " " & "y="; b & " ∑=" & j - nEnd IfNext nElseans = MsgBox("出错", 48, "提示信息")Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""Form1.ClsEnd IfElseIf Option2.Value = True ThenIf Val(Text1) <= 0 And Val(Text2) >= 0 And Val(Text3) <= 0 And Val(Text4) >= 0 And Option2.Value = True ThenPrint "初始:进给方向 " & "F(m)=0" & " X0=" & Int(Text1) & " Y0=" & Int(Text2) & " ∑ = " & jFor n = 1 To jIf F(m) >= 0 Thenm = m + 1l = l + 1F(m) = F(m - 1) - 2 * Abs(b) + 1Picture1.Line (4500 + Int(Text1) * e - e * k, 4000 - Int(Text2) * e + (l - 1) * e)-(4500 + Int(Text1) * e - e * k, 4000 - Int(Text2) * e + l * e)b = b - 1Form1.CurrentX = 15000Form1.CurrentY = 200 + n * 300Print "第" & m & "步" & " -△y F(" & m & ")= " & F(m) & " " & "x=" & a & " " & "y="; b & " ∑=" & j - nElsek = k + 1m = m + 1Picture1.Line (4500 + Int(Text1) * e - e * (k - 1), 4000 - Int(Text2) * e + l * e)-(4500 + Int(Text1) * e - e * k, 4000 - Int(Text2) * e + l * e)F(m) = F(m - 1) + 2 * Abs(a) + 1a = a - 1Form1.CurrentX = 15000Form1.CurrentY = 200 + n * 300Print "第" & m & "步" & " -△x F(" & m & ")= " & F(m) & " " & "x=" & a & " " & "y="; b & " ∑=" & j - nEnd IfNext nElseans = MsgBox("出错", 48, "提示信息")Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""Form1.ClsEnd IfElseIf Option3.Value = True ThenIf Val(Text1) <= 0 And Val(Text2) <= 0 And Val(Text3) <= 0 And Val(Text4) <= 0 And Option3.Value = True ThenPrint "初始:进给方向 " & "F(m)=0" & " X0=" & Int(Text1) & " Y0=" & Int(Text2) & " ∑ = " & jFor n = 1 To jIf F(m) >= 0 Thenm = m + 1k = k + 1F(m) = F(m - 1) - 2 * Abs(a) + 1Picture1.Line (4500 + Int(Text1) * e + e * (k - 1), 4000 - Int(Text2) * e + l * e)-(4500 + Int(Text1) * e + e * k, 4000 - Int(Text2) * e + l * e)a = a + 1Form1.CurrentX = 15000Form1.CurrentY = 200 + n * 300Print "第" & m & "步" & " +△x F(" & m & ")= " & F(m) & " " & "x=" & a & " " & "y="; b & " ∑=" & j - n Elsel = l + 1m = m + 1F(m) = F(m - 1) + 2 * Abs(b) + 1Picture1.Line (4500 + Int(Text1) * e + e * k, 4000 - Int(Text2) * e + (l - 1) * e)-(4500 + Int(Text1) * e + e * k, 4000 - Int(Text2) * e + l * e)b = b - 1Form1.CurrentX = 15000Form1.CurrentY = 200 + n * 300Print "第" & m & "步" & " -△y F(" & m & ")= " & F(m) & " " & "x=" & a & " " & "y="; b & " ∑=" & j - nEnd IfNext nElseans = MsgBox("出错", 48, "提示信息")Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""Form1.ClsEnd IfEnd IfEnd IfEnd SubPrivate Sub Command4_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""Picture1.ClsForm1.ClsPicture1.ForeColor = vbBlackPicture1.DrawWidth = 2Picture1.Line (0, 4000)-(9000, 4000)Picture1.Line (4500, 0)-(4500, 8000)End SubPrivate Sub Command5_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""Picture1.ClsForm1.ClsEnd SubPrivate Sub Command6_Click()EndEnd SubPrivate Sub Command7_Click()End Sub。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Private Sub Command1_Click()Const pi = 3.14159265Picture1.ForeColor = vbBlackPicture1.DrawWidth = 2Picture1.Line (50, 500)-(50, 5500)Picture1.Line (50, 5500)-(6500, 5500)Picture1.Line (80, 600)-(50, 500)Picture1.Line (20, 600)-(50, 500)Picture1.Line (6400, 5450)-(6500, 5500) Picture1.Line (6400, 5550)-(6500, 5500) Picture1.ForeColor = vbRedPicture1.DrawWidth = 3If Int(Text1) = 0 ThenPicture1.Circle (50, 5500), Sqr(Int(Text1) *Int(Text1) + Int(Text2) * Int(Text2)) * 400, , Atn(Int(Text4) / Int(Text3)), pi / 2ElsePicture1.Circle (50, 5500), Sqr(Int(Text1) *Int(Text1) + Int(Text2) * Int(Text2)) * 400, , Atn(Int(Text4) / Int(Text3)), Atn(Int(Text2) /Int(Text1))End IfEnd SubPrivate Sub Command2_Click()Dim k, m, j, l, n, F(20) As Integerm = 0l = Text1.Textk = Text2.TextF(m) = 0Picture1.ForeColor = vbGreenPicture1.DrawWidth = 3j = Abs(Int(Text1) - Int(Text3)) + Abs(Int(Text2) - Int(Text4))Form1.CurrentX = 200Form1.CurrentY = 200 Print "初始:进给方向 " & "F(m)=0" & " X0=" & Int(Text1) & " Y0=" & Int(Text2) & " ∑ = " & jFor n = 1 To jIf F(m) >= 0 And j > 0 Thenm = m + 1k = k - 1F(m) = F(m - 1) - 2 * Abs(k + 1) + 1Picture1.Line (50 + 400 * l, 5500 - k * 400)-(50 + 400 * l, 5500 - (k + 1) * 400)Form1.CurrentX = 200Form1.CurrentY = 200 + m * 300Print "第" & m & "步" & " -△y F(" & m & ")= " & F(m) & " " & "x=" & l & " " & "y="; k & " ∑=" & j - nElsel = l + 1m = m + 1Picture1.Line (50 + 400 * l, 5500 - k * 400)-(50 + 400 * (l - 1), 5500 - k * 400)F(m) = F(m - 1) + 2 * Abs(l - 1) + 1Form1.CurrentX = 200Form1.CurrentY = 200 + m * 300Print "第" & m & "步" & " +△x F(" & m & ")= " & F(m) & " " & "x="; l & " " & "y="; k & " ∑=" & j - nEnd IfNext nEnd SubPrivate Sub Command3_Click()Text1.Text = ""Text3.Text = ""End SubPrivate Sub Command4_Click()EndEnd SubPrivate Sub Command1_Click()Picture1.ForeColor = vbBlackPicture1.DrawWidth = 2Picture1.Line (7500, 8500)-(7500, 500)Picture1.Line (7500, 500)-(500, 500)Picture1.Line (7500, 8500)-(7400, 8400)Picture1.Line (7500, 8500)-(7600, 8400)Picture1.Line (500, 500)-(600, 600)Picture1.Line (500, 500)-(600, 400)Picture1.ForeColor = vbRedPicture1.DrawWidth = 5Picture1.Line (7500, 500)-(7500 + 400 *Int(Text3), 500 - 400 * Int(Text4))End SubPrivate Sub Command2_Click()Form1.ClsDim k, m, j, l, n, F(20) As Integerm = 0l = 0k = 0F(m) = 0Picture1.ForeColor = vbGreenPicture1.DrawWidth = 3j = Abs(Int(Text3)) + Abs(Int(Text4))Form1.CurrentX = 200Form1.CurrentY = 200Print "初始:进给方向 " & "F(m)=0" & " Xe=" & Int(Text3) & " Ye=" & Int(Text4) & " ∑ = " & jFor n = 1 To jIf F(m) >= 0 And j > 0 Thenm = m + 1l = l - 1F(m) = F(m - 1) - Abs(Int(Text4)) Picture1.Line (7500 + 400 * (l + 1), 500 - k * 400)-(7500 + 400 * (l), 500 - k * 400)Form1.CurrentX = 200Form1.CurrentY = 200 + m * 300Print "第" & m & "步" & " △x F(" & m & ")= "& F(m) & " " & "x=" & l & " " & "y="; k & " ∑=" & j - nElsek = k - 1m = m + 1Picture1.Line (7500 + 400 * l, 500 - (k + 1) * 400)-(7500 + 400 * l, 500 - k * 400)F(m) = F(m - 1) + Abs(Int(Text3))Form1.CurrentX = 200Form1.CurrentY = 200 + m * 300Print "第" & m & "步" & " △y F(" & m & ")= " & F(m) & " " & "x="; l & " " & "y="; k & " ∑=" & j - nEnd IfNext nEnd SubPrivate Sub Command3_Click()Text1.Text = ""Text2.Text = ""Picture1.ClsForm1.ClsEnd SubPrivate Sub Command4_Click()EndEnd SubPrivate Sub Form_Load()End SubPrivate Sub Command1_Click()Const pi = 3.14159265Picture1.ForeColor = vbBlackPicture1.DrawWidth = 2Picture1.Line (50, 500)-(50, 5500)Picture1.Line (50, 5500)-(6500, 5500)Picture1.Line (80, 600)-(50, 500)Picture1.Line (20, 600)-(50, 500)Picture1.Line (6400, 5450)-(6500, 5500)Picture1.Line (6400, 5550)-(6500, 5500)Picture1.ForeColor = vbRedPicture1.DrawWidth = 3Picture1.Line (50, 5500)-(50 + 400 * Int(Text3), 5500 - 400 * Int(Text4))End SubPrivate Sub Command2_Click()Dim k, m, j, l, n, F, G As Integerl = 0 k = 0 F = 0 G = 0Picture1.ForeColor = vbGreenPicture1.DrawWidth = 3n = Int(Text5)j = 2 ^ nm = 2 ^ nForm1.CurrentX = 200Form1.CurrentY = 200Print "累加次数 " & "F= F + int (text3)" & " +△X " & " G=G +int(text4)" & " +△Y "; ∑ = " & j"Print " n " & " 0 " & " 0 " & " 0 " & " 0 " & jFor n = 1 To mF = F + Int(Text3)G = G + Int(Text4) If F >= m And G >= m Thenl = l + 1 k = k + 1Picture1.Line (50 + 400 * (l - 1), 5500 - (k - 1) * 400)-(50 + 400 * (l), 5500 - k * 400)F = F - mG = G - mPrint " "; n & " " & F & " " & 1 & " " & G & " " & 1 & " " & j - 1ElseIf F >= m And G < m Thenl = l + 1F = F - mPrint " "; n & " " & F & " " & 1 & " " & G & " " & 0 & " " & j - 1Picture1.Line (50 + 400 * (l - 1), 5500 - k * 400)-(50 + 400 * (l), 5500 - k * 400)ElseIf F < m And G >= m Thenk = k + 1 G = G - mPicture1.Line (50 + 400 * l, 5500 - (k - 1) * 400)-(50 + 400 * (l), 5500 - k * 400)Print " "; n & " " & F & " " & 0 & " " & G & " " & 1 & " " & j - 1ElseIf F < m And G < m ThenPrint " "; n & " " & F & " " & 0 & " " & G & " " & 0 & " " & j - 1End Ifj = j - 1Next nEnd SubPrivate Sub Command3_Click()Text1.Text = ""Text2.Text = ""Picture1.ClsForm1.ClsEnd SubPrivate Sub Command4_Click()End End Sub。