资源描述:
《逐点比较法插补c语言程序源代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、逐点比较法插补c语言程序源代码#include"conio.h"#include"graphics.h"#include"process.h" #defineNi_circle0 #defineShun_circle1 voidinit_graph(); voiddraw_Base_circle();voiddraw_cabu_circle(); voidclose_graph(); voidacrroods(); staticfloatx0,y0; voidline_cabu(),draw_line(
2、),draw_line_cabu(); voidline_cabu() /*此函数控制直线插步两次*/ { inti; init_graph(); sleep(1); for(i=0;i<2;i++) { line(0,120,300,120);outtextxy(310,120,"Z"); line(100,10,100,300);outtextxy(110,300,"X"); outtextxy(90,13
3、0,"O"); draw_line(); if(i==0) draw_line_cabu(6); elsedraw_line_cabu(2); gotoxy(50,5); getch(); cleardevice(); setcolor(WHITE); } } voiddraw_line()/*画直线*/ { line(100,120,600,450); textcolor
4、(YELLOW); directvideo=0; gotoxy(45,5);cprintf("Linefrom:X0 Y0Z0"); gotoxy(45,6);cprintf("Lineto:X500Y0Z330"); gotoxy(45,7);cprintf("Units :Pixel"); gotoxy(45,8);cprintf("Linenow:"); } voiddraw_line_cabu(intstep)/*关键的直线插补函数*/ { intXe=60
5、0,Ye=450; floatFm,Xm=100,Ym=120; setcolor(RED); moveto(Xm,Ym); while(Xm<=Xe&&Ym<=Ye) { Fm=(Ym-120)*(Xe-100)-(Xm-100)*(Ye-120); if(Fm>=0) Xm=Xm+step; else
6、Ym=Ym+step; lineto(Xm,Ym); gotoxy(55,8);printf("X%3.0f Y0Z%3.0f",Xm-100,Ym-120); delay(1100); } } /*圆插补部分的函数区*/ voidinit_graph() /*图形系统初始化*/ { intgdrive=DETECT,gmode; initgraph(&gdri
7、ve,&gmode,""); cleardevice(); } voidacrroods() /*屏幕中心坐标*/ { x0=getmaxx()/2; y0=getmaxy()/2; } voiddraw_Base_circle() /*画圆及写参数*/ { line(x0-200,y0,x0+200,y0);outtextxy(x0+220,y0,"Z"); line(x0,y0-180,x0,y0+180);
8、outtextxy(x0+10,y0+180,"X"); outtextxy(x0-10,y0+10,"O"); circle(x0,y0,150); textcolor(YELLOW); directvideo=0; gotoxy(46,2);cpr