Page 50 - DCAP504_Computer Graphics
P. 50

Unit 4: Scan Conversion I



               Consider the difference between these two distance values: s-t
               1.   If s-t is less than zero, s<t and the closest pixel is S.
               2.   If s-t is greater than zero, s>t and the closest pixel is T.
               3.   If s-t is equal to zero then we have to choose T.

               The difference may be represented in the following way:
               s-t= (y-y i )-[(y i +1)-y]
                    =2y-2y i -1

                    =2m(x i +1)+2b-2y i -1
               If we substitute m by ∆y/∆x and introduce a decision variable d i =∆x(s-t), we get:

               d i =2∆y*x i -2∆x*y i +C  (C=2∆y+∆x(2b-1))
               In the same way, we may write decision variable di+1 for the next step as follows:
               d i +1=2∆y*x i +1-2∆x*y i +1+C

               d i +1-d i =2∆y(x i+1 -x i )-2∆x(y i+1 -y i )
               As x i+1 =x i +1 we get

               d i+1 =d i +2∆y-2∆x(y i+1-y i)
               If the top pixel T is chosen then yi+1=yi+1
               d i+1=di+2∆y-∆x
               If the bottom pixel S is chosen then yi+1=yi
               di+1=di+2∆y

               Hence we have
               di+1={di+2(∆y-∆x) if di≥0
               di+1={di+2∆y         if di<0
               d1 may be calculated from the original definition of the decision variable di:
               d1=∆x [2m(x1+1) +2b-2y1-1]
                   =∆x [2(mx1+b-y1) +2m-1]

               As mx1+b-y1=0 and m=∆y/∆x, we have
               d1=2∆y-∆x
               4.3   Circle
               A circle is a symmetrical figure. Any circle-generating algorithms may be used to plot eight points for
               each value that the algorithm calculates. As shown in the figure 4.3, only one octant of the circle has to
               be generated. A successive reflection obtains the other parts. If the first octant (0 to 45 ) is generated the
                                                                                    0
               second octant can be obtained by reflection through the line y = x to yield the first quadrant. The results
               in the first quadrant are returned through line x = 0, to obtain those in the second quadrant.













                                        LOVELY PROFESSIONAL UNIVERSITY                           43
   45   46   47   48   49   50   51   52   53   54   55