直线裁剪c语言,计算机图形学CohenSutherland直线裁剪算法源码c

41528d3028836879cd698677c3999917.gif计算机图形学CohenSutherland直线裁剪算法源码c

Cohen-Sutherland 直线段裁减算法实验报告实验现象:核心代码:Cohen-Sutherland 直线段裁减算法:void CLineClippingView::OnSutherlandID() 版权所有 赵才{// TODO: Add your command handler code hereCDC* pDC=GetDC();CPen newpen(PS_SOLID,1,RGB(255,255,0));CPen *old=pDC-SelectObject(// RedrawWindow();//绘制 N 条直线段;// pDC-MoveTo(ptset[i]);// pDC-LineTo(ptset[i+1]);int i=0;while(iMoveTo(ptset[i]);pDC-LineTo(ptset[i+1]);i+=2;continue;}else{if((code1 continue;}else{if(code1==0){int tx,ty,ct;ct=code1;code1=code2;code2=ct;tx=ptset[i].x;ty=ptset[i].y;ptset[i].x= ptset[i+1].x;ptset[i].y= ptset[i+1].y;ptset[i+1].x=tx;ptset[i+1].y=ty;// pDC-MoveTo(ptset[i]);// pDC-LineTo(ptset[i+1]);}float k=float(ptset[i+1].y-ptset[i].y)/float(ptset[i+1].x-ptset[i].x);if(code1 ptset[i].x=XL;continue;}if(code1 ptset[i].x=XR;continue;} if(code1 ptset[i].y=YT;continue;} if(code1 ptset[i].y=YB;continue;} }} }}int encode(int x,int y) //确定端点编码{ int c=0;if(xXR) c|=RIGHT;if(yYB) c|=BOTTOM;if(yYT) c|=TOP;return c;}实验心得:注意运算符的优先级,勤加括号

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值