An efficient line clipping algorithm based on adaptive line rejection

Abstract Line clipping process often involves a lot of intersection calculations. One way for improving the efficiency of a line clipping algorithm is to save the unnecessary intersection calculations demanded by traditional algorithms either for rejecting some totally invisible lines or for clipping some partially visible lines. An adaptive clipping algorithm is presented here to achieve this goal. The clipping process of our new algorithm consists of three steps. Firstly, we adopt Encoding & Code checking technique of Cohen–Sutherland algorithm to accept the totally visible lines and reject the portion of invisible lines that lie completely on the outside of each boundary of the clip window. Secondly, we construct a diamond enclosing box of the original window called S-Window to reject another portion of invisible lines that cross the corner of the clip window. All the remaining lines are identified at the third step. For each line, we construct a virtual enclosing box of the original window, called V-Window, which aligns with the line’s direction. All of invisible lines that fail to be rejected during the previous two steps are now easily picked up without any intersection calculations. The remaining partially visible lines are clipped against the boundary edges of the window that they do intersect. Theoretical analysis and experimental statistics demonstrate the high efficiency of our new algorithm.