TL;DR: This paper proposes a new line clipping algorithm against a convex polygon with O (N) time complexity and it could be observed that the endpoints of completely outside line segments coincide after the pruning process.
Abstract: This paper proposes a new line clipping algorithm against a convex polygon with O (N) time complexity. The line segment is pruned against each extended edge of the polygon as the first step of the proposed algorithm. Then, the pruning process gives accurate outcomes for completely inside and partially inside line segments only. It could be observed that the endpoints of completely outside line segments coincide after the pruning process. The algorithm was developed based on this observation. The proposed algorithm was compared against the four existing algorithms both theoretically and experimentally. The proposed algorithm is faster than Cyrus Beck algorithm and it is slower than ECB, Rappaport, and Skala algorithms.
Keywords: Computer Graphics Programming, Line Clipping Algorithms, Computational Geometry, Convex Analysis, Time Complexity.
TL;DR: In this article, a new approach to line clipping by a convex polygon problem solution is presented, based on a separation function, which separates the polygon vertices to the left or right hand side of the given line.
Abstract: This paper presents a new approach to line clipping by a convex polygon problem solution. The algorithm is based on a separation function, which separates the polygon vertices to the left or right hand side of the given line. It leads to numerically robust algorithms in comparison to the well-known Cyrus-Beck’s algorithm and its modifications.
TL;DR: The salient feature of the proposed algorithm is that it minimizes the number of computations by ignoring unnecessary intersection calculations, and needs minimum details about the convex polyhedron; the equations of the facets and the centroid.
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 10 8 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.
TL;DR: The main advantage of the presented algorithm is the substantial acceleration of the line clipping problem solution and that edges can be oriented clockwise or anti-clockwise.