**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.