机床数控技术课程设计姓名:王毅辉学号:050610525指导老师:王宏涛2010.01.15目录:一:课程设计要求………………………………………………3二:DDA直线插补……………………………………………41.DDA法直线插补流程图…………………………………42.DDA法直线插补源程序…………………………………53.实现的情况………………………………………………9三:逐点比较法圆弧插补……………………………………101.逐点比较法圆弧插补流程图……………………………102.逐点比较法圆弧插补源程序……………………………113.实现情况…………………………………………………20四:总计与体会………………………………………………20一:课程设计的要求:1.DDA法直线插补第1象限2.采用逐点比较法插补第2-1象限顺圆弧。3.具有数据输入界面,如起点、终点、圆心、半径及插补步长等4.具有插补过程的动态显示功能,如单步插补、连续插补5.插补步长可调,直线的起点、圆弧圆心在坐标系中位置可调。6建议用C语言编程,也可以使用VB、VC等语言编程。二、DDA法直线插补1、流程图求num的值起始并初始化yi<=0yi>0ry有溢出-y走一步rx有溢出NY+x走一步Ynum=num-1num=0?Yry有溢出+y走一步rx有溢出NY-x走一步Ynum=num-1num=0?结束YNyi<=0NYN2、源程序:PrivateSubCommand1_Click()OnErrorGoToBUGDimxsAsDouble,ysAsDouble,xeAsDouble,yeAsDouble,stepAsDouble,x0AsDouble,y0AsDoubleDimxiAsDouble,yiAsDouble,DimvxAsDouble,vyAsDouble,rxAsDouble,ryAsDouble,numAsDoublevx=0vy=0rx=0ry=0num=0xs=Text1.Textys=Text2.Textxe=Text3.Textye=Text4.Textstep=Text5.Textx0=xsy0=ysxi=x0yi=y0num=Abs(xe-xs)/step+Abs(ye-ys)/stepvx=Abs(xe-xs)vy=Abs(ye-ys)picture1.CurrentX=x0picture1.CurrentY=y0If(xe>xs)And(ye>ys)ThenDoWhile(num>0)rx=rx+Abs(vx)ry=ry+Abs(vy)If(rx>256)Thenxi=xi+steprx=rxMod256num=num-1waittime(0.01)EndIfIf(ry>256)Thenyi=yi+stepry=ryMod256num=num-1waittime(0.01)EndIfpicture1.Line-(xi,yi)LoopEndIfIf(xe<=xs)And(ye>ys)ThenDoWhile(num>0)rx=rx+Abs(vx)ry=ry+Abs(vy)If(rx>256)Thenxi=xi-steprx=rxMod256num=num-1waittime(0.01)EndIfIf(ry>256)Thenyi=yi+stepry=ryMod256num=num-1waittime(0.01)EndIfpicture1.Line-(xi,yi)LoopEndIfIf(xe<=xs)And(ye<=ys)ThenDoWhile(num>0)rx=rx+Abs(vx)ry=ry+Abs(vy)If(rx>256)Thenxi=xi-steprx=rxMod256num=num-1waittime(0.01)EndIfIf(ry>256)Thenyi=yi-stepry=ryMod256num=num-1waittime(0.01)EndIfpicture1.Line-(xi,yi)LoopEndIfIf(xe>xs)And(ye<=ys)ThenDoWhile(num>0)rx=rx+Abs(vx)ry=ry+Abs(vy)If(rx>256)Thenxi=xi+steprx=rxMod256num=num-1waittime(0.01)EndIfIf(ry>256)Thenyi=yi+stepry=ryMod256num=num-1waittime(0.01)EndIfpicture1.Line-(xi,yi)LoopEndIfExitSubBUG:MsgBox("出错了~~重新填数值~~^_^")EndSub3、实现情况:本程序是DDA法的直线插补程序,不仅实现了第1象限的插补,同时可以实现所有象限的直线插补过程。在写程序的时候考虑到再第1象限仅仅实现从原点到某点的直线插补比较容易实现,可以将不从原点开始的直线通过坐标转移或相对坐标地法转化为从原点开始的直线,并且几个象限情况类似。故支持四个象限的直线插补三.逐点比较法圆弧插补1、流程图2、源程序:PrivateSubCommand2_Click()OnErrorGoToBUG1起始E=Xe+YeE>0直线走向Y左上方+Y走一步-X走一步F≥0f=(lym-lyn)*(xn-lxn)-(yn-lyn)*(lxm-lxn)F≥0+X走一步N+Y走一步f=(yn-yn)*(lxm-lxn)-(lym-lyn)*(xn-lxn)左下方-Y走一步-X走一步F≤0f=(yn-lyn)*(lxm-lxn)-(lym-lyn)*(xn-lxn)右下方-Y走一步+X走一步F≤0f=(lym-lyn)*(xn-lxn)-(yn-lyn)*(lxm-lxn)E←E-1结束N右上方YNYNNYYDimxsAsDouble,ysAsDouble,xeAsDouble,yeAsDouble,x0AsDouble,y0AsDoubleDimxiAsDouble,yiAsDouble,stepAsDouble,rAsDouble,FAsDoubleDimnumAsIntegerstep=Text6.Textxs=Text7.Textys=Text8.Textxe=Text9.Textye=Text10.Textx0=Text11.Texty0=Text12.Textr=Sqr((xs-x0)*(xs-...