International Journal of Computer Graphics Vol. 6, No.1 (2015), pp.1-12 http://dx.doi.org/10.14257/ijcg.2015.6.1.01 ISSN: 2093-9663 IJCG Copyright ⓒ 2015 SERSC Line Clipping against Arbitrary Polygonal Window Bimal Kumar Ray School of Information Technology & Engineering VIT University, Vellore – 632014, India [email protected], [email protected]Abstract The Cyrus-Beck algorithm clips line against convex polygonal window, but it fails to clip line against concave and self-intersecting window because of the underlying assumption made in the design of the algorithm. This paper extends Skala`s algorithm to design and develop a line clipping algorithm that clips a line against arbitrary polygonal window – any number of sides, convex, concave and self-intersecting and in contrast to the Cyrus-Beck algorithm, it does not compute false intersection. Keywords: Line clipping, arbitrary polygonal window, function of separation 1. Introduction Removing a portion of a line against a region is known as line clipping. Since a graphics image may consist of line segments, it is necessary to device algorithm that performs line clipping. Line clipping has its application in geographic information system, VLSI circuits design, designing building architecture – to mention a few. The region (window) against which clipping is performed is usually rectangular with sides parallel to the coordinate axes but clipping against arbitrary window is also of interest and this is why the Cyrus-Beck algorithm was extended to clip a line against arbitrary convex polygonal window. A number of algorithms for line and line segment clipping had been developed for rectangular as well as polygonal convex window. The Cohen-Sutherland algorithm [1] clips a line segment against rectangular upright window after coding the end points of the line segment using four-bit vector. Unfortunately, it computes false intersection point and cannot be extended to clip line segment against arbitrary window (any number of sides, convex, concave, self-intersecting). The Cyrus-Beck algorithm [2] clips line and line segment against convex window. It computes intersection of the clipping object with every side of the clipping window and consequently the maximum number of false intersection points is as large as the number of sides of the clipping window. Moreover, this algorithm cannot clip a line against concave and self-intersecting window. An efficient version of the Cyrus-Beck algorithm was proposed by Liang and Barsky [3] but this algorithm too has the same drawback as that of Cyrus-Beck. The Nicholl-Lee-Nicholl algorithm [4] introduced ′test and intersect′ approach instead of ′intersect and test′ and thereby avoided computing false intersection. The algorithm operates on upright rectangular clipping window and cannot be extended to clipping window of arbitrary polygonal shape. Skala proposed an algorithm [5] for line clipping showing improvement over the Cyrus-Beck algorithm. Skala [6] also proposed an O(lg N) algorithm for line clipping against convex window. An O(1) algorithm for line clipping in E2 was also proposed by him [7]. Bui and Skala [8] suggested modifications of the Cohen-Sutherland algorithm for clipping lines and line segments based on coding the direction of line and coding the end points of a line segment. In [9], Skala used homogeneous coordinates and developed line and line segment clipping algorithm. For line segment clipping, outcode is used to encode the end points of the line segment. Apart from other advantages, the
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
From the results in the Table I it may be observed that the performance of the proposed
algorithm CL1 is not better than that of the Cyrus-Beck algorithm. But Cyrus-Beck
algorithm computes false intersection points whereas CL1 does not.
The Table II shows the mean, standard deviation and the three-sigma limits of the
execution time of the lines for the implementation of CL2 for convex polygon.
Comparing these results with the Cyrus-Beck algorithm shows that as long as convex
polygonal clipping window is used CL2 does not show improvement over the Cyrus-Beck
algorithm.
International Journal of Computer Graphics
Vol. 6, No.1 (2015)
Copyright ⓒ 2015 SERSC 9
Table II. The Mean (μ), Standard Deviation (σ) and Three-Sigma Limits of Time to Clip a line against arbitrary polygon (convex, concave, self-
intersecting) with Different Number of Sides (n)
n
CL2
μ σ μ – 3σ μ + 3σ
3 2.60e−07 9.17e−08 −1.50e−08 5.35e−07
4 3.36e−07 9.33e−08 5.61e−08 6.16e−07
5 4.46e−07 8.42e−08 1.94e−07 6.98e−07
6 5.34e−07 9.40e−08 2.52e−07 8.16e−07
8 7.38e−07 9.25e−08 4.61e−07 1.02e−06
The advantage of the proposed algorithm CL2 is that it can clip a line against concave
and self-intersecting polygonal window whereas Cyrus-Beck can clip a line if the clipping
window is convex but it cannot clip a line if the clipping window is concave and self-
intersecting.
The algorithm CL2 was tested widely along with the Cyrus-Beck algorithm for a wide
variety of clipping window with arbitrary number of sides and arbitrary topology –
convex, concave and self-intersecting – with lines after generating the clipping window
and the lines randomly. The experiments show that the Cyrus-Beck algorithm fails to clip
a line whenever the clipping window is concave and self-intersecting. The Figure 5 shows
some of these results for concave and self-intersecting clipping window with vertices
varying from five to twelve. The dashed line shows the input line and the continuous line
segment(s) is/are the output segment(s). The left column of the figure shows the output
produced by the Cyrus-Beck algorithm and the right one shows that produced by CL2. It
may be observed from these figures that the Cyrus-Beck algorithm does not return any
results as the clipping polygons are concave and/or self-intersecting.
International Journal of Computer Graphics
Vol. 6, No.1 (2015)
10 Copyright ⓒ 2015 SERSC
International Journal of Computer Graphics
Vol. 6, No.1 (2015)
Copyright ⓒ 2015 SERSC 11
Figure 5. Clipping Window, Line to be Clipped (shown in Dashed Line) and Clipped Line Segment(s) (shown as Continuous Line. The Left Column Shows the Output of the Cyrus-Beck Algorithm and the Right Column
Shows the Output of the Proposed Algorithm CL2. The Clipping Polygons with Number of Sides Varying from Five to Twelve Only are shown here
6. Conclusion
Skala`s algorithm [9] has been extended successfully for clipping a line against
polygonal window of arbitrary topology (convex, concave, self-intersecting). Though the
performance of the algorithm CL1 and CL2 is not better than that of the Cyrus-Beck
algorithm, but the Cyrus-Beck algorithm cannot clip a line whenever the clipping polygon
is concave and self-intersecting. Moreover, the Cyrus-Beck algorithm detects false
intersection points whereas the proposed algorithm by virtue of its ′test and evaluate′
approach does not compute false intersection point. The algorithm CL2 is found to work
consistently on a wide variety of clipping windows with arbitrary number of sides and of
arbitrary shapes. The algorithm will benefit in an increase in speed if vector – vector
operations and/or parallel processing is used. The cross-product processor too will
increase the performance significantly.
References
[1] J. D. Foley, A. van Dam, S. K. Finer and J. F. Hughes, Computer Graphics: Principles and Practice,
Addison-Wesley, (2nd edition in C), (1996).
[2] M. Cyrus and J. Beck, Generalized two-and three-dimensional clipping, Computers & Graphics, 2(1),
pp. 23 – 28, (1978).
[3] Y. Liang and B. Barsky, A new concept and method for line clipping, ACM Transactions on Graphics
3(1), pp. 1 – 22, (1984).
[4] T. M. Nicholl, D. T. Lee and R. A. Nicholl, An efficient new algorithm for 2-D line clipping: its
development and analysis. In : SIGGRAPH Proceedings 21(4), pp. 253–262, (1987).
[5] V. Skala, An efficient algorithm for line clipping by convex polygon. Computers & Graphics, 17(4), pp.
417–421, (1993).
[6] V. Skala, O(lg N) line clipping algorithm in E2, Computers & Graphics, 18(4), pp. 517–524, (1994).
[7] V. Skala, Line Clipping in E2 with O(1) Processing Complexity, Computers & Graphics 20(4), pp. 523–
530, (1996).
International Journal of Computer Graphics
Vol. 6, No.1 (2015)
12 Copyright ⓒ 2015 SERSC
[8] D. H. Bui and V. Skala, Fast algorithms for clipping lines and line segments in E2, The Visual
Computer, 14(1), pp. 31 – 37, (1998).
[9] V. Skala, A new approach to line and line segment clipping in homogeneous coordinates, Visual
Computer, 21, pp. 905–914 (2005).
Author
Bimal Kumar Ray, received B.Sc. Honours degree in
Mathematics from St. Xavier`s College, Kolkata, M. Sc.
degree in Applied Mathematics from Calcutta University,
Kolkata and Ph.D. degree in Computer Science from Indian
Statistical Institute, Kolkata. His areas of interests are
Computer Graphics, Vision and Image Processing. He had
published a number of papers in peer-reviewed journals.