0
24kviews
Explain Liang-Barsky line clipping algorithm with example. OR Write a line clipping algorithm which uses parametric form of equation.
1 Answer
4
1.5kviews

Liang-Barsky line clipping algorithm:-

Liang and Barsky have developed more efficient algorithm than Cyrus-Beck algorithm, using parametric equations and is also efficient than Cohen-Sutherland algorithm . The parametric equations are given as,

enter image description here

The point clipping conditions for Liang-Barsky approach in the parametric form can be given as

enter image description here

Liang-Barsky expresses these four inequalities with two parameters p and q as follows:

enter image description here

where parameters p and q are defined as

enter image description here enter image description here enter image description here

Liang-Barsky algorithm calculates two values of Parameter t : t1 and t2 that define that part of the line that lies within the clip rectangle. The value of t1 is determined by checking the rectangle edges for which the line proceeds from the outside to the inside (p <0). The value of t1 is taken as a largest value amongst various values of intersections with all edges. On the other hand, the value of t2 is determined by checking the rectangle edges for which the line proceeds from the inside to the outside (p > 0). The minimum of the calculated value is taken as a value for t2.

Now, if t1 > t2, the line is completely outside the clipping window and it can be rejected. Otherwise the values of t1 and t2 are substituted in the parametric equations to get the end points of the clipped line.

enter image description here enter image description here enter image description here

Please log in to add an answer.