• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
September 06, 2022 |990 Views
Cyrus-Beck Line Clipping Algorithm in Computer Graphics
Description
Discussion

In this video, we will be covering Cyrus Beck is a line clipping algorithm that is used for convex polygons.  This algorithm performs line clipping for non-rectangular windows. 

For example: 
Let the given input is set of coordinates of convex area of interest, which are in clockwise fashion, vertices (x,y), ‘n’ number of vertices, a line that has to be clipped is set of coordinates and array of coordinates are (x0, y0) and (x1, y1) 

Output : The line clipping coordinates are accepted clipping and rejected clipping coordinates are (-1, -1). 

Algorithm: 
Step 1: Every edge of normal edge is calculated. 
Step 2: Clipping line of vector is calculated. 
Step 3: Perform the product operation between the difference of one vertex per edge and one selected end point of the clipping line and the normal of the edge is calculated . 
Step 4: Perform product operation between the vector of the clipping line and the normal of edge is calculated. 
Step 5: The former dot product as to be divided with latter dot product and multiplied by -1. 
Step 6: The values of ‘t’ are entering or exiting (from all edges) by observing their 
denominators (latter dot product). 
Step 7: From each group one value of ‘t’ has to be chosen, 
and represent into parametric form of a line to calculate the coordinates. 
Step 8: Suppose, the entered ‘t’ value is greater than the existing ‘t’ value, 
then the clipping line has to be rejected. 

Cyrus-beck Line clipping algorithm advantages:
1) It is more efficient when compared to Cohen–Sutherland algorithm, which uses repetitive clipping. 
2) With a convex polygon clipping window it can be used unlike Cohen-Sutherland, that can be used only on a rectangular clipping area. 

Cyrus-beck line clipping algorithm disadvantages: 
1) The main disadvantage of this algorithm is that it can be applied only to a two-dimensional clipping, whereas other methods like Liang-Barsky and the Cohen-Sutherland can easily extended to three- dimensional scenes. 

Cyrus-beck line clipping algorithm: https://www.geeksforgeeks.org/line-clipping-set-2-cyrus-beck-algorithm/

Read More