收藏 分享(赏)

直线段裁剪算法.ppt

上传人:hwpkd79526 文档编号:9105816 上传时间:2019-07-24 格式:PPT 页数:21 大小:666KB
下载 相关 举报
直线段裁剪算法.ppt_第1页
第1页 / 共21页
直线段裁剪算法.ppt_第2页
第2页 / 共21页
直线段裁剪算法.ppt_第3页
第3页 / 共21页
直线段裁剪算法.ppt_第4页
第4页 / 共21页
直线段裁剪算法.ppt_第5页
第5页 / 共21页
点击查看更多>>
资源描述

1、直线段裁剪的Liang-Barsky算法,线段裁剪的意义Liang-Barsky算法,0 问题的提出,线段裁剪就是将指定窗口作为图形边界,将窗口内的线段保留,而窗口外的线段则被舍弃。,1.线段裁剪的意义,Before clipping,After clipping,裁剪处理涉及:(1)线段在窗口内外的判别;(2)线段与窗口的求交。,2.Liang-Barsky 算法,(1)算法背景经典算法-写入图形学教科书的唯一中国人算法,Sutherland,梁友栋,苏步青,Barsky,梁友栋的贡献:Liang-Barsky算法 几何连续理论 Communication of ACM 论文(83),193

2、5年7月出生,福建福州人.,1956年毕业于复旦大学数学系,1960年复旦大学数学系研究生毕业1960年分配到浙江大学数学系任教,1979年至1981年在美国Utah大学计算机系作访问学者 获国家教委科技进步一等奖,1987 获国家自然科学三等奖,1991,60sCohen-Sutherland的编码方法:,Cohen,Sutherland,78年Cyrus和Beck的参数化方法-更有效的算法:,84年梁友栋和Barsky提出了更快的参数化线段裁剪算法。,(2) 算法思想,Liang-Barsky算法的几何含义:入边、出边和端点,Parameterized line segment: x =

3、x1 + u(x2 x1) = x1 + uDx y = y1 + u (y2 y1) = y1 + uDy 0 u 1,If a point on the line is inside the clipping window, then:xmin x1 + uDx xmaxymin y1 + uDy ymax,xmin x1 +uDx = ( Dx) u x1 xmin,We rewrite the inequalities in the form upk qkLeft Border, k= 1: pk = Dx, qk= x1 xmin Right Border, k= 2: pk = D

4、x, qk= xmax x1 Bottom Border, k=3: pk = Dy, qk= y1 ymin Top Border, k=4: pk = Dy, qk= ymax y1,x1 + uDx xmax = (Dx) u xmax x1,ymin y1 + uDy = ( Dy) u y1 ymin,y1 + uDy ymax = (Dy) u ymax y1,Case 1: pk 0,If pk 0, then the extension of the line segment goes from inside to outside.The order of going from

5、 inside to outside and outside to inside the boundaries indicates whether we need to clip.To determine this, we solve for u for the intersection of the line with each of the extended boundaries:uk = qk / pk,Case 2: pk = 0,If pk = 0, then the line is parallel to the border of the clipping window that

6、 corresponds to k (e.g. the left border for k=1). if qk 0, the line is completely outside the clipping window. It can be discarded. if qk 0,the line is inside the boundary and further consideration.,ymax,If x2 = x1 then p1 and p2 are zero. q2= xmax x1 0 Discard line.,(3)The Liang-Barsky Algorithm,1

7、If pk=0 and qk0,calculate rk=qk / pk. Let u2=minrk ,1. 4 If u1 u2,discard the line since it is completely outside the clipping window. Otherwise, use u1 and u2 to calculate endpoints of the clipped line.,裁减的插曲: 汪嘉业的快速算法 80年代的裁减热:应道宁、汪国昭等 对三种算法比较: Cohen-Sutherland与中点法在区域码测试阶段能以位运算方式高效率的进行,因而当大多数线段能够简单的取舍时,效率较好。 梁友栋Barskey算法只能应用于矩形窗口的情形,但其效率比前两者要高,这是因为运算只涉及到参数,仅到必要时才进行坐标计算。,(4)算法演示,Go!,百闻不如一见!,(5)课下练习:1.关于Liang-Barsky算法的效率,现在有人提出了怀疑,到互联网上搜集资料,提出你的看法. 2.用以下界面实现Liang-Barsky算法:,讲课结束,谢谢!,

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报