Aug2016 cs Q18

0. 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 :

  • Option : 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.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *