Computer Engineering and Applications 计算机工程与应用 2012 ,48 (34) 175
一种改进的Sutherland-Cohen 裁剪算法
李竹林,雷 岗
LI Zhulin, LEI Gang
延安大学 计算机学院,陕西 延安 716000
Institute of Computer Science, Yan ’an University, Yan ’an, Shaanxi 716000, China
LI Zhulin, LEI Gang. Modified Sutherland-Cohen line clipping algorithm. Computer Engineering and Appli-
cations, 2012, 48 (34 ):175-178.
Abstract :Cohen-Sutherland clipping algorithm is lower efficiency because of four intersection operations of line
segment and window edge lines. In this paper, a modified Sutherland-Cohen line clipping algorithm is proposed.
The line in the window or out the window completely is judged. The auxiliary line is decided according by the cod-
ing of a line endpoint, and one of edges of the window is deduced to compute the point of intersection with the line
by the relation of three points on a plane. The modified algorithm makes intersection operation be twice at most,
avoiding to compute the slope and distance, can improve the efficiency of the algorithm greatly. The thought is simple,
the operation is convenient, hardware implementation is easy, and is important practical value for graphics applications.
Key words :Cohen-Sutherland clipping algorithm; line classification; auxiliary line; sign
摘 要:Cohen-Sutherland裁剪算法因直线与窗口边界求交点次数多而降低算法效率。提出了一种改进Sutherland-
Cohen 裁剪算法,将完全在窗口内和窗口外的直线判断出来,根据直线端点编码确定辅助线,利用平面上三点
的关系判断直线与窗口的哪条边相交。改进的算法使得求交点次数降为最多两次,且避免计算斜率与距离,
大大提高算法的效率。算法思想简单,操作方便,有利于硬件实现,对图形学的应用具有重要的实用价值。
关键词:Cohen-Sutherland 裁剪算法;直线分类;辅助线;符号
文献标识码:A 中图分类号:TP301 doi :10.3778/j.issn. 1002-8331.1105-0213
线段裁剪技术在计算机图形图像处理中占有重 进思想分为两类:第一类是将完全在窗口之外的线
要的地位,裁剪速度的高低直接影响到图形应用效 段作出判断,减少不必要的求交运算,但计算量较大;
果。线段裁剪是复杂图元裁剪的基础,各种非线性 另一类是降低线与窗口边线的最高求交次数,却引入
边界均可以用直线段来近似。目前广泛使用的三种 了除法运算。本文提出了一种改进Sutherland-Cohen
经典直线裁剪算法是Sutherland-Cohen 裁剪算法、中 裁剪算法,首先将完全在窗口之