Page 145 - DCAP504_Computer Graphics
P. 145

Computer Graphics



                          The Liang-Barsky algorithm  combines the above parametric line equations with the point clipping
                          conditions to obtain the inequalities as below:

                          xw min ≤x 0  + u   ∆ x  ≤xw max
                          yw min ≤y 0  + u ∆  y  ≤yw max
                          The above equation can be split into four separate equations:

                          xw min ≤ x 0  + u ∆  x
                          xw max  ≥x 0  + u  ∆ x

                          yw min  ≤y 0 + u ∆ y
                          yw max  ≥y 0  + u ∆  y
                          Each of these inequalities  specifies  the limits set for each clipping boundary. The first equation
                          corresponds to the left hand boundary, the second equation corresponds to the right hand boundary,
                          the third equation corresponds to the lower boundary, and the fourth equation corresponds to the
                          upper boundary. These four inequalities can be expressed as:
                          u.p k ≤  q k    where k = 1, 2, 3, 4
                          The parameters p and q can be defined as:
                          k = 1    p 1 = -  ∆  x    q 1 = x 0 - xw min

                          k = 2    p 2 =   ∆  x    q 2 = xw max - x 0
                          k = 3    p 3 = -  ∆  y   q 3 = y 0 - yw min

                          k = 4   p 4 =   ∆  y     q 4 = yw max - y 0
                          Consider k =1, the parameters defined for this value are p 1 = -  ∆  x  and q 1  = x 0  -  xw min. Now insert
                          these into the equation u.p k   ≤ q k . The result obtained is:
                          -  ∆ x ≤ x 0 - xw min
                          Now rearranging the equation you will get:

                          xw min ≤ x 0 + u  ∆ x
                          This indicates that k = 1 corresponds to the limits set by the left hand clipping boundary.
                          The line parallel to one of the clipping window edges has p k = 0. Here, the value of k corresponds to
                          that boundary  where k = 1,  2, 3, and 4 corresponding to left, right, bottom and upper boundaries
                          respectively. For that value of k, if q k < 0 then the line lies outside the clipping boundary. If q k > 0, then
                          the line is inside the clipping boundary.

                          If p k < 0, then the line extends from outside to inside the infinite extension of the clipping window edge.
                          If p k > 0, then the line extends from inside to outside. If p k value is nonzero, then the value of u, which
                          corresponds to the point where the extended line intersects the extension of the clipping window edge,
                          can be calculated using the below equation:
                          u = q k / p k















                          138                     LOVELY PROFESSIONAL UNIVERSITY
   140   141   142   143   144   145   146   147   148   149   150