对Cohen-Sutherland线段裁剪算法的改进
Improvement in the Algorithm of Cohen-Surtherland Segment Clipping
-
摘要: 针对Cohen-Sutherland线段编码裁剪算法仅是孤立地处理被裁减线段两端点这一弊端,提出一种基于Cohen-Sutherland线段裁剪算法的改进算法,它充分利用线段的整体信息,构造出合理分割窗口的辅助线以对线段与窗口相对位置关系进行更精确的判断,避免无效交点的计算,使线段与窗口交点的计算量降到最低水平,提高裁剪的整体效率.该改进处理思路同样适用于其他的裁剪算法.Abstract: In the algorithm of Cohen-Sutherland segment clipping, two terminal points of the clipped segment are encoded respectively according to the areas in which they locate. Using the codes the segments which do not intersect with any boundary of the clipping window or its extending would be determined rapidly. But the idea that studies every terminal point respectively makes no use of the segment information and brings on the inefficient work for the segment which intersect with the boundaries of the window or their extendings. Here much improvement is made to make good use of the information of the segment itself. Some assistant lines are created to partition the clipping window, then according to the feature of the area which the clipped segment belongs to, the relationship of the location between the segment and the window can be distinguished well and truly. So the calculation of the cross-points is performed only when it is needed. This means a faster clipping algorithm. And the idea in the paper would hold true for other clipping algorithms.