Question: Explain Liang-Barsky line clipping algorithm with example. OR Write a line clipping algorithm which uses parametric form of equation.
0

Subject: Computer Graphics

Topic: Two Dimensional Viewing and Clipping

Difficulty: High

cg(14) • 3.3k views
 modified 14 months ago  • written 15 months ago by vbadbe • 70
0

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,

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

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

where parameters p and q are defined as

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.