- It is more efficient than cohen and sutherland line algorithm liang barsky.
- liang barsky has developed the algorithm using the parametric equation are:
x= x1+TX
y= y1+TY
where X= x1-x2, Y= y1-y
- The point clipping condition for liang barsky are:
xw min <= x1+TX <= xw max
yw min <= y1+TY <=yw max
- Liang barsky express these four with two parameter p and q as t pi<qi where i=1,2,3.......
where the parameter p and q are :
p1 = -X , p2 = X , p3= -Y , p4 = Y and q1 = x1-xw min , q2= xw max- x1 , q3= y1-yw min , q4= yw max - y1
- If pi= 0 then line is parallel to i th boundary where i=1,2,3......
- If qi= 0 then line is completely outside the boundary so we can discard the line.
- The non zero value of pi the line cross the clipping boundary and we have to find the parameter 't'. where t= qi/pi
- this algorithm find the two value of 't' such as 't1' and 't2'.
- The value of 't1' is taken as the largest value among various values of intersection with all edges i.e; pi < 0. and The value of 't2' is taken as the smallest value i.e; pi > 0.
- if (t1<t2) then some formulas are used to find the ends points .
- xx1= x1+t1X
- xx2= x1+ t2X
- yy1= y1+ t1Y
- yy2 = y2+t2Y (Then draw the line)
ADVANTAGES OF LIANG BARSKY ALGORITHM
- It is more efficient then sutherland and cohen algorithm because intersection calculation are reduce.
- It required only one division to update parameter p1 and p2.
- Window intersection of the lines are computed only once.
Posted in clipping, Liang barsky line clipping algorithm, line clipping algorithm
Shearing | Sheared transformation