UGC-NET | UGC NET CS 2016 Aug – III | Question 18

The Liang-Barsky line clipping algorithm uses the parametric equation of a line from (x1, y1) to (x2, y2) along with its
infinite extension which is given as :
x = x1 + ∆x.u
y = y1 + ∆y.u
Where ∆x = x2– x1, ∆y = y2– y1, and u is the parameter with 0 < u < 1. A line AB withend points A(–1, 7) and B(11, 1) is to be clipped against a rectangular window with xmin = 1, xmax = 9, ymin = 2, and ymax = 8. The lower and upper bound values of the parameter u for the clipped line using Liang-Barsky algorithm is given as :
(A) (0, 2/3)
(B) (1/6 , 5/6)
(C) (0, 1/3)
(D) (0, 1)


Answer: (B)

Explanation: first we will calculate ∆x and ∆y:
i.e. ∆x = x2– x1
= 11 – ( – 1)
= 11 + 1
= 12.
∆y = y2– y1
= 1 – 7
= – 6
Now P1 = -∆x = – 12
P2 = ∆x = 12
P3 = -∆y = 6
P4 = ∆y = – 6
Q1 = x1 – xmin = – 1 – 1 = -2
Q2 = xmax – x1 = 9 – ( – 1) = 9 + 1 = 10.
Q3 = y1 – ymin = 7 – 2 = 5.
Q4 = ymax – y1 = 8 -7 = 1.
P1, P4 < 0 and P2, P3 > 0.
Intially: t1 = 0, t2 = 1
t1 = max(0, Q1 / P1, Q4 / P4)
= max(0, 2 / 12, 1 / -6)
= 1 / 6.
t2 = min(1, Q1 / P1, Q4 / P4)
= min(1, 10 / 12, 5 /6).
= 5 / 6.
i.e. u ranges between (1 / 6, 5 / 6).
So, option (B) is correct.


Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.