AN APPROACH FOR LINE CLIPPING AGAINST A CONVEX POLYHEDRON
Abstract
Line clipping operation is a bottleneck in most of computer graphics applications. There are situations when millions of line segments need to be clipped against convex polyhedrons with millions of facets. An algorithm to clip line segments against a convex polyhedron is proposed in this work. The salient feature of the proposed algorithm is that it minimizes the number of computations by ignoring unnecessary intersection calculations. The other advantage of the proposed algorithm is that it needs minimum details about the convex polyhedron; the equations of the facets and the centroid. Therefore, it improves the efficiency of the algorithm. The line segment may have zero length (a point) or positive length. When line segment is just a point which is outside with respect to at least one facet, it should be rejected as the line segment is outside the convex polyhedron. When the line segment is parallel to a facet and one of its end points is outside, that line segment is also completely outside and it should also be rejected. Unless the line segment belongs to none of the above two cases, it should be pruned against each facet in a certain order. In this case, the intersection points with only some of the facets need to be computed and some other intersection calculations can be ignored. If the line segment is completely outside then it becomes a single point. That means the two end points coincide. But due to the precision error they do not exactly coincide. Therefore, approximate equality should be tested. By using this property, completely outside line segments can be identified. Having two end points outside does not necessarily keep the line segment completely outside. The widely used Cyrus Beck algorithm computes all the intersection points with each facet of the polyhedron while the proposed algorithm successfully avoids some of the intersection point calculations. In the best case; it is capable of avoiding all the unnecessary intersection calculations. An experimental comparison between the Cyrus Beck algorithm and the proposed algorithm was carried out. Random polyhedrons were created with different number of facets. Random points were generated and they were considered as end points of line segments. For a given polyhedron, the number of clock cycles consumed to clip 108 number of line segments was computed using the Cyrus Beck algorithm and the proposed algorithm. For a polyhedron with four vertices, the proposed algorithm is 1.02 times faster than the Cyrus Beck algorithm. For a polyhedron with nine vertices, the proposed algorithm is 1.16 times faster than the Cyrus Beck algorithm. When the number of facts is large, then the performance of the proposed algorithm is significantly faster since more intersection calculations are avoided. The proposed approach could be very useful for applications where large number of lines to be clipped. It can also be applied in linear programming as well since it can be extended to arbitrary dimensions.References
D. Hearn and M. P. Baker (1998), Computer Graphics, C Version, 2nd Edition, Prentice Hall, Inc., Upper Saddle River, pp. 224-248.
W. Huang (2010), The Line Clipping Algorithm Based on Affine Transformation, Intelligent Information Management, Volume. 2, pp. 380-385.
S. R. Kodituwakku, K. R. Wijeweera, M. A. P. Chamikara (2013), An Efficient Algorithm for Line Clipping in Computer Graphics Programming, Ceylon Journal of Science (Physical Sciences), Volume. 17, pp. 1 – 7.
CS 535 NOTES CYRUS-BECK CLIPPING ALGORITHM, http://cs1.bradley.edu/public/jcm/cs535CyrusBeck.html; accessed on 20 July 2012.
Downloads
Published
Issue
Section
License
From Volume 7 (2016) onwards, all articles published in Ruhuna Journal of Science are Open Access articles published under the Creative Commons CC BY-NC 4.0 International License. This License permits use, distribution and reproduction in any medium, provided the original work is properly cited and is not used for commercial purposes.
Copyright on any research article published in RJS is retained by the respective author(s).
Authors who publish with this journal agree to the following terms:
a) Authors retain copyright and grant the journal right of first publication with the work simultaneously licensed under a Creative Commons Attribution License CC-BY-NC 4.0 International, that allows others to share the work with an acknowledgement of the work's authorship and initial publication in this journal.
b) Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgement of its initial publication in this journal.
c) Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See The Effect of Open Access).