版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 机床数控技术课程设计 说明书班级:学号:姓名:指导教师:时间说明书课设任务: DL2 ,DDA法插补第二象限直线 PA34,逐点比较法插补第3-4象限逆圆弧课设要求: 具有数据输入界面,如起点、终点、圆心、半径及插补步长等 具有插补过程的动态显示功能,如单步插补、连续插补 插补的步长可调编程语言: Visual Basic程序设计流程图: DDA法插补第二象限直线:J = J + F ; K = K + G初始化L=A,M=B,累加次数N=0-2I(J / (2 I) >= E(K/(2 I) >= EN-x向走一步+Y向走一步画直线NYYN=N+1N=2I吗?结束NY 逐点比较
2、法插补第3-4象限逆圆弧: 开始初始化Xp=X1;Yp=Y1;F1=0F1>=0F1 = F1 - (2 * (Yp - Y0) + U 2;Yp = Yp - UF1 = F1 + (2 * (Xp X0) + U 2;Xp = Xp + UNY画直线Xp < X0 And Xp < X2F1>=0NYF1 = F1 + (2 * (Xp - X0) + U 2: Xp = Xp + UF1 = F1 + (2 * (Yp - Y0) + U 2: Yp = Yp + UXp > X2N画直线NYXp < X2 Or Yp < Y2结束NYY变量说明
3、、源程序Dim A!, B!, C!, D!, E!, F!, G!, H!, I!, J!, K!, L!, M!, N!, P!, Q!Dim X1!, X2!, X3!, F1!, Xp!, Yp!, Y1!, Y2!, Y3!, X0!, Y0!, R!, S!, T!, U!, V!, W!, X!, Y!, Z!,o1!Private Sub Command1_Click() *直线DDA连续插补A = Text1.TextB = Text2.Text 直线起点坐标(A,B)C = Text3.TextD = Text4.Text 直线终点坐标(C,D)E = Text5.Text
4、 直线插补步长F = (A - C)G = (D - B)Picture1.Line (A, B)-(C, D)If F > G Then H = F Else: H = GI = 1Do While (2 I) <= HI = I + 1LoopJ = 0K = 0L = AM = BFor N = 0 To (2 I) Step 1J = J + FP = LIf (J / (2 I) >= E Then J = J - E * (2 I): L = L - EK = K + GQ = MIf (K / (2 I) >= E Then K = K - E * (2
5、I): M = M + EPicture1.Line (P, Q)-(L, M), vbRedNext NEnd SubPrivate Sub Command2_Click() *圆弧单步逐点插补X1 = Text6.TextY1 = Text7.TextX2 = Text8.TextY2 = Text9.TextR = Text10.TextU = Text11.TextDim xe, ye As Singlexe = (X1 + X2) / 2ye = (Y1 + Y2) / 2S = Sqr(X2 - X1) 2 + (Y2 - Y1) 2) / 2T = (Y2 - Y1) / (X2
6、 - X1)If Y1 = Y2 Then X0 = (X1 + X2) / 2 Y0 = Y1 + Sqr(R 2 - S 2) ElseIf Y1 < Y2 Then X0 = xe - Sqr(R 2 - S 2) * T 2 / (1 + T 2) Y0 = (xe - X0) / T + ye ElseIf Y1 > Y2 Then X0 = xe + Sqr(R 2 - S 2) * T 2 / (1 + T 2) Y0 = (xe - X0) / T + yeEnd IfIf (X0 < X1 And Y0 >= Y2) Then X = 2 * 3.14
7、 + Atn(Y1 - Y0) / (X1 - X0): Y = 2 * 3.14 + Atn(Y2 - Y0) / (X2 - X0)If (X0 = X1 And Y0 >= Y2) Then X = (3 * 3.14 / 2): Y = 2 * 3.14 + Atn(Y2 - Y0) / (X2 - X0)If (X0 > X1 And X0 < X2 And Y0 >= Y1 And Y0 >= Y2) Then X = 3.14 + Atn(Y1 - Y0) / (X1 - X0): Y = 2 * 3.14 + Atn(Y2 - Y0) / (X2
8、- X0)If (X0 > X2 And Y0 >= Y1) Then X = 3.14 + Atn(Y1 - Y0) / (X1 - X0): Y = 3.14 + Atn(Y2 - Y0) / (X2 - X0)If (X0 = X2 And Y0 >= Y1) Then X = 3.14 + Atn(Y1 - Y0) / (X1 - X0): Y = (3 * 3.14) / 2Picture1.Circle (X0, Y0), R, , X, YSelect Case (o1 = 0)Case 1F1 = 0Xp = X1Yp = Y1o1 = 1End Select
9、If (Xp >= X1 And Xp < X0 And Xp < X2) Then If F1 >= 0 Then F1 = F1 + (2 * (Xp - X0) + U 2: V = Xp: Xp = Xp + U Picture1.Line (V, Yp)-(Xp, Yp), vbBlue Else F1 = F1 - (2 * (Yp - Y0) + U 2: W = Yp: Yp = Yp - U Picture1.Line (Xp, W)-(Xp, Yp), vbBlue End IfElseIf (Xp >= X0 And (Xp < X2
10、Or Yp < Y2) Then Select Case (Xp > X2) Case 0 If F1 >= 0 Then F1 = F1 + (2 * (Yp - Y0) + U 2: W = Yp: Yp = Yp + U Picture1.Line (Xp, W)-(Xp, Yp), vbBlue Else F1 = F1 + (2 * (Xp - X0) + U 2: V = Xp: Xp = Xp + U Picture1.Line (V, Yp)-(Xp, Yp), vbBlue End If End SelectEnd IfEnd SubPrivate Sub
11、Command4_Click() *圆弧连续逐点插补X1 = Text6.TextY1 = Text7.Text 圆弧起点坐标(X1,Y1)X2 = Text8.Text Y2 = Text9.Text 圆弧终点坐标(X2,Y2)R = Text10.Text 圆弧半径U = Text11.Text 圆弧插补步长Dim xe, ye As Singlexe = (X1 + X2) / 2ye = (Y1 + Y2) / 2 S = Sqr(X2 - X1) 2 + (Y2 - Y1) 2) / 2T = (Y2 - Y1) / (X2 - X1)If Y1 = Y2 Then X0 = (X1
12、 + X2) / 2 Y0 = Y1 + Sqr(R 2 - S 2) ElseIf Y1 < Y2 Then X0 = xe - Sqr(R 2 - S 2) * T 2 / (1 + T 2) Y0 = (xe - X0) / T + ye ElseIf Y1 > Y2 Then X0 = xe + Sqr(R 2 - S 2) * T 2 / (1 + T 2) Y0 = (xe - X0) / T + ye 圆弧圆心(X0,Y0)End IfIf (X0 < X1 And Y0 >= Y2) Then X = 2 * 3.14 + Atn(Y1 - Y0) /
13、(X1 - X0): Y = 2 * 3.14 + Atn(Y2 - Y0) / (X2 - X0)If (X0 = X1 And Y0 >= Y2) Then X = (3 * 3.14 / 2): Y = 2 * 3.14 + Atn(Y2 - Y0) / (X2 - X0)If (X0 > X1 And X0 < X2 And Y0 >= Y1 And Y0 >= Y2) Then X = 3.14 + Atn(Y1 - Y0) / (X1 - X0): Y = 2 * 3.14 + Atn(Y2 - Y0) / (X2 - X0)If (X0 > X
14、2 And Y0 >= Y1) Then X = 3.14 + Atn(Y1 - Y0) / (X1 - X0): Y = 3.14 + Atn(Y2 - Y0) / (X2 - X0)If (X0 = X2 And Y0 >= Y1) Then X = 3.14 + Atn(Y1 - Y0) / (X1 - X0): Y = (3 * 3.14) / 2Picture1.Circle (X0, Y0), R, , X, YF1 = 0Xp = X1Yp = Y1Do While (Xp >= X1 And Xp < X0 And Xp < X2) If F1 &
15、gt;= 0 Then F1 = F1 + (2 * (Xp - X0) + U 2: V = Xp: Xp = Xp + U Picture1.Line (V, Yp)-(Xp, Yp), vbRed Else F1 = F1 - (2 * (Yp - Y0) + U 2: W = Yp: Yp = Yp - U Picture1.Line (Xp, W)-(Xp, Yp), vbRed End If LoopDo While (Xp >= X0 And (Xp < X2 Or Yp < Y2) Select Case (Xp > X2) Case 0 If F1 &
16、gt;= 0 Then F1 = F1 + (2 * (Yp - Y0) + U 2: W = Yp: Yp = Yp + U Picture1.Line (Xp, W)-(Xp, Yp), vbRed Else F1 = F1 + (2 * (Xp - X0) + U 2: V = Xp: Xp = Xp + U Picture1.Line (V, Yp)-(Xp, Yp), vbRed End If End Select LoopEnd SubPrivate Sub Command5_Click() *DDA单步直线插补A = Text1.TextB = Text2.TextC = Tex
17、t3.TextD = Text4.TextE = Text5.TextF = (A - C)G = (D - B)Picture1.Line (A, B)-(C, D)If F > G Then H = F Else: H = GI = 1Do While (2 I) <= HI = I + 1LoopSelect Case (L = C Or M = D)Case 0 P = L Q = MDo While (P = L And Q = M)If (K / (2 I) >= E Then K = K - E * (2 I): M = M + EK = K + GIf (J
18、/ (2 I) >= E Then J = J - E * (2 I): L = L - EJ = J + FLoopPicture1.Line (P, Q)-(L, M), vbBlueEnd SelectEnd SubPrivate Sub Command3_Click() *直线清图Picture1.ClsPicture1.Scale (-21, 21)-(21, -21)Picture1.Line (-20, 0)-(20, 0)Picture1.Line (0, -20)-(0, 20)Picture1.Line (20, 0)-(19.5, 0.3)Picture1.Line
19、 (20, 0)-(19.5, -0.3)Picture1.Line (0, 20)-(0.3, 19.5)Picture1.Line (0, 20)-(-0.3, 19.5)Dim X4!, Y4!X4 = -20Y4= -20Do While X4 < 19X4 = X4 + 1Picture1.Line (X4, 0)-(X4, 0.2)LoopDo While Y4 < 19Y4 = Y4 + 1Picture1.Line (0, Y4)-(0.2, Y4)LoopL = AM = BJ = 0K = 0Picture1.CurrentX = 20Picture1.Curr
20、entY = -1Picture1.Print "X"Picture1.CurrentX = 1Picture1.CurrentY = 20Picture1.Print "y"End SubPrivate Sub Command6_Click() *圆弧清图Picture1.ClsPicture1.Scale (-21, 21)-(21, -21)Picture1.Line (-20, 0)-(20, 0)Picture1.Line (0, -20)-(0, 20)Picture1.Line (20, 0)-(19.5, 0.3)Picture1.Lin
21、e (20, 0)-(19.5, -0.3)Picture1.Line (0, 20)-(0.3, 19.5)Picture1.Line (0, 20)-(-0.3, 19.5)Dim X4!, Y4!X4 = -20Y4 = -20Do While X4 < 19X4 = X4 + 1Picture1.Line (X4, 0)-(X4, 0.2)LoopDo While Y4 < 19Y4 = Y4 + 1Picture1.Line (0, Y4)-(0.2, Y4)Loopo1 = 0Picture1.CurrentX = 20Picture1.CurrentY = -1Pic
22、ture1.Print "X"Picture1.CurrentX = 1Picture1.CurrentY = 20Picture1.Print "y"End SubPrivate Sub Command7_Click() *清数据Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""Text7.Text = ""Text8.Text = ""Text9.Text = ""Text10.Text = ""
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 五金材料采购实践分享
- 2022年四川省广元市公开招聘警务辅助人员辅警笔试自考题1卷含答案
- 2022年安徽省合肥市公开招聘警务辅助人员辅警笔试自考题2卷含答案
- 2022年四川省广安市公开招聘警务辅助人员辅警笔试自考题1卷含答案
- 2021年贵州省铜仁市公开招聘警务辅助人员辅警笔试自考题1卷含答案
- 2025年工具钢项目提案报告模范
- 广西北海市(2024年-2025年小学六年级语文)统编版随堂测试((上下)学期)试卷及答案
- 2025年出入口机项目立项申请报告模范
- 实习生的辞职报告
- 2024年服务器项目资金需求报告代可行性研究报告
- 手术室抢救工作制度
- ce自我声明模板
- 钢闸门监理评估报告
- 高档养老社区项目计划书
- 京东物流信息系统
- 蛇年销售年会发言稿范文
- 国管局住房制度改革相关政策解答
- 无缝钢管服务方案
- 排涝泵站养护方案范本
- XX医院临床医疗质量考核通用记录表
- 城市交通枢纽运营故障应急预案
评论
0/150
提交评论