Page 54 - DCAP504_Computer Graphics
P. 54

Unit 4: Scan Conversion I



               Dnew = F (xp + 2, yp −3/2)
               Dnew = (xp+ 2)2 + (yp −3/2)2 −R2
               Dnew = (x2p+ 4xp + 4) + (y2p −3yp +9/4) −R2
               Dnew = (x2p+ 2xp + 1) + (2xp + 3) + (y2/p −yp +1/4) + (−2yp +8/4) −R2

               Dnew = (xp+ 1) 2 + (yp −1/2)2 −R2 + (2xp + 3) + (−2yp + 2)
               Dnew = D+ (2xp −2yp + 5)
               Thus the new value of D would be the current value + (2(xp − yp) + 5).
               The last issue is computing the initial value of D. Since we start at x = 0, y = R the first midpoint of
               interest is at x = 1, y = R−1=2, so the initial value of D is

               Dinit = F (1 R−1/2)
               = 1 + (R−1/2)2 −R2
               = 1+R2−R+1/4−R2
               =5/4−R:
               You can make a very clever observation at this point is for testing if D is positive or negative. If we
               change the value of D, we do so by an integer increment. Thus, D is always of the form D0 + 1=4, where
               D0 is an integer. Such a quantity is positive if and only if D0 is positive. Hence you can ignore this extra
                                      −
               1=4 term, initialize Dinit = 1R and the algorithm will work exactly in the same way that it should
               work.
               4.4   Ellipse
               An ellipse is a smooth curve which results about its horizontal and vertical axes. Like circles ellipse also
               show symmetry. Ellipse is a four-way symmetry. The equation of an ellipse is given by the following
               equation:

                                                   x 2  +  y 2  = 1
                                                   a 2   b 2
               Therefore,
               F(x, y) = b 2x 2  + a2y 2 - a2b 2 = 0
               The curvature of an ellipse is different at different points. Hence, we must divide the first quadrant into
               two unequal parts. Considering a tangent over this part of the ellipse, we see that it has a variable slope
               in the range [—∞, 0]. In the upper part, the curve is near the horizontal axis and in the lower part it is
               near the vertical axis. We can express the equation of the tangent to the ellipse in vector notation by
               computing the gradient of the ellipse, at any point (x, y).  The x-component of the tangent vector is
               greater in the upper part, and the y-component is higher in the lower part. Thus, the point of division,
               corresponds to a point where both of these components are equal in magnitude.
               Now, the gradient of the elliptic curve at any point (x, y) is:
                                                           f δ   f δ
                                             ∇ { xf (  , y) }=  i +  j
                                                           x δ   y δ

                                                                +
                                                                 2=  b 2 xi 2 a  2 yj
               As mentioned earlier, at the point of division the x- and y- components are equal in magnitude, with the
               x- component greater in upper part and y-component in the lower part. Thus, if at any point on the
               ellipse, a2(Yp – ½) ≤ b2(Xp + 1), we switch from region 1 to region 2 as shown in Figure 4.6.






                                        LOVELY PROFESSIONAL UNIVERSITY                           47
   49   50   51   52   53   54   55   56   57   58   59