逐点比较法的c语言编程,逐点比较法直线插补c语言程序

1 一 逐点比较法插补程序 include conio h include graphics h include process h define Ni circle 0 define Shun circle 1 void init graph void draw Base circle void draw cabu circle void close graph void acrroods static float x0 y0 void line cabu draw line draw line cabu void line cabu 此函数控制直线插步两次 int i 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 130 O draw line if i 0 draw line cabu 6 else draw line cabu 2 gotoxy 50 5 getch cleardevice setcolor WHITE void draw line 画直线 line 100 120 600 450 textcolor YELLOW directvideo 0 gotoxy 45 5 cprintf Line from X0 Y0 Z0 gotoxy 45 6 cprintf Line to X500 Y0 Z330 gotoxy 45 7 cprintf Units Pixel gotoxy 45 8 cprintf Line now void draw line cabu int step 关键的直线插补函数 2 int Xe 600 Ye 450 float Fm Xm 100 Ym 120 setcolor RED moveto Xm Ym while Xm Xe else Ym Ym step lineto Xm Ym gotoxy 55 8 printf X 3 0f Y0 Z 3 0f Xm 100 Ym 120 delay 1100 圆插补部分的函数区 void init graph 图形系统初始化 int gdrive DETECT gmode initgraph cleardevice void acrroods 屏幕中心坐标 x0 getmaxx 2 y0 getmaxy 2 void draw Base circle 画圆及写参数 line x0 200 y0 x0 200 y0 outtextxy x0 220 y0 Z line x0 y0 180 x0 y0 180 outtextxy x0 10 y0 180 X outtextxy x0 10 y0 10 O circle x0 y0 150 textcolor YELLOW directvideo 0 gotoxy 46 2 cprintf Circle start X0 Y0 Z150 gotoxy 46 3 cprintf Circle end X0 Y0 Z150 gotoxy 46 4 cprintf Units Pixel gotoxy 46 5 cprintf Circle now void close graph 关图形系统 3 closegraph void draw cabu circle int sstep int Directory 关键的圆插补函数 int flag 0 float Fm Xm Ym Xm x0 150 Ym y0 moveto Xm Ym setcolor RED while 1 分象限 顺圆和逆圆讨论 Fm Xm x0 Xm x0 Ym y0 Ym y0 150 150 圆判断公式 if Fm 0 if Directory 逆圆判断 if Xm x0 if 语句判断象限 以下一样 else Xm Xm sstep if Xm x0 Ym Ym sstep if Xm y0 Xm Xm sstep if Xm x0 else it is Directory s else if Xm x0 if Xm x0 if Xmy0 flag 1 Ym Ym sstep if Xm x0 Xm Xm sstep else it is Fm s else if Directory if Xm x0 else Ym Ym sstep if Xm x0 Xm Xm sstep if Xm y0 Ym Ym sstep if Xm x0 else if Xm x0 if Xm x0 if Xm y0 flag 1 Xm Xm sstep if Xm x0 else Ym Ym sstep lineto Xm Ym gotoxy 58 5 printf X 3 0f Y0 Z 3 0f Ym y0 Xm x0 delay 800 void circle demo int Directory 控制圆插补两次 int i 0 sstep init graph sleep 2 acrroods for i 0 i 2 i draw Base circle 150 if i 0 sstep 6 draw cabu circle sstep Directory else sstep 1 draw cabu circle sstep Directory 5 getch cleardevice setcolor WHITE 圆插补部分的函数区结束 main 主函数负责写封面和函数调用 int choice 0 init graph while choice 4 setfillstyle 1 RED bar 200 30 400 80 setcolor GREEN settextstyle 3 0 10 outtextxy 220 50 DEMO PROGRAM BY P Y F setcolor WHITE settextstyle 0 0 1 outtextxy 200 120 1 Line demo outtextxy 200 140 2 Shun Circle demo outtextxy 200 160 3 Ni Circle demo outtextxy 200 180 4 Quit the program outtextxy 160 200 Please enter your choice gotoxy 46 13 scanf d switch choice case 1 line cabu break case 2 circle demo Ni circle break case 3 circle demo Shun circle break case 4 break default printf nChoice wrong try again close graph

展开阅读全文

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值