makecode(x0, y0,c1); makecode(x2, y2, c2); while (c1!=0 || c2!=0) {
if (c1&c2!=0) {
//显示线段,此时绘制的是分割完后,完全在窗口外同侧的线段 showline(x0, y0, x2, y2); return;
}
c=c1; if (c==0) c=c2;
if (c&1==1) {y=y0+(y2-y0)*(x1-x0)/(x2-x0); x=x1;} else if (c&2==2) {y=y0+(y2-y0)*(xr-x0)/(x2-x0); x=xr;} else if (c&4==4) {x=x0+(x2-x0)*(yb-y0)/(y2-y0); y=yb;} else if (c&8==8) {x=x0+(x2-x0)*(yt-y0)/(y2-y0); y=yt;} if (c==c1)
{showline(x0,y0,x,y);//绘制被分割抛弃的线段 x0=x; y0=y; makecode(x, y, c1);}
else
{showline(x,y,x2,y2);//绘制被分割抛弃的线段 x2=x; y2=y; makecode(x, y, c2);} } }
此算法已经编码实现并测试通过。
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库计算机图形学第3章作业答案 - Final -(5)在线全文阅读。
相关推荐: