电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

SutherlandHodgman多边形裁剪算法VIP免费

SutherlandHodgman多边形裁剪算法_第1页
SutherlandHodgman多边形裁剪算法_第2页
SutherlandHodgman多边形裁剪算法_第3页
Sutherland_Hodgman 多边形裁剪算法 #define TRUE 1 #define FALSE 0 typedef struct { float x, y; } vertex; void intersect(p1, p2, clipboundary, intersectp) vertex p1, p2, *clipboundary, *intersectpt; /* p1 和p2 为多边形的边的起点和终点,clipboundary 为窗口边界,intersectpt 中返回边与窗口边界的交点 */ { if ( clipboundary[0].y== clipboundary[1].y ) /* 水平边界 */ { intersectpt->y = clipboundary[0].y; intersectpt->x = p1.x + (clipboundary[0].y-p1.y)*(p2.x-p1.x)/(p2.y-p1.y); } else /* 垂直边界 */ { intersectpt->x = clipboundary[0].x; intersectpt->y = p1.y + (clipboundary[0].x-p1.x)*(p2.y-p1.y)/(p2.x-p1.x); } } int inside(testvertex, clipboundary) vertex testvertex, *clipboundary; /* 如果顶点testvertex 在窗口边界clipboundary 的内部,那么返回TRUE;否则返回FALSE */ { if ( clipboundary[1].x < clipboundary[0].x ) /* 上边界 */ if ( testvertex.y <= clipboundary[0].y ) return TRUE; if ( clipboundary[1].x > clipboundary[0].x ) /* 下边界 */ if ( testvertex.y >= clipboundary[0].y ) return TRUE; if ( clipboundary[1].y > clipboundary[0].y ) /* 右边界 */ if ( testvertex.x <= clipboundary[0].x ) return TRUE; if ( clipboundary[1].y < clipboundary[0].y ) /* 左边界 */ if ( testvertex.y <= clipboundary[0].x ) return TRUE; return FALSE; } outputvertex(outvertex, outlength, outvertexlist) vertex outvertex; int *outlength; vertex *outvertexlist /* 向输出顶点序列中输出顶点outvertex */ { outvertexlist[*outlength] = outvertex; (*outlength)++; } void Sutherland_Hodgman_Polygon_Clipping(invertexlist, outvertexlist, inlength, outlength, clipboundary) vertex *invertexlist, *outvertexlist; int inlength, *outlength; vertex *clipboundary; /* invertexlist 为输入顶点序列,inlength 为输入序列长度;outvertexlist 为输出顶点序列,outlenght 中返回输出序列长度;clipboundary 为窗口边界 */ { vertex s, p, i; int j; *ou...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部