Page 72 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 72

Lab on Computer Graphics



                   Notes         Output
                                 Enter the Radius Value: (Rx, Ry) =10, 30
                                 Enter the xcenter and ycenter Values: =300,150

                                                In 1970 Danny Cohen presented at the “Computer Graphics 1970” conference
                                                in England a linear algorithm for drawing ellipses and circles.

                                 5.2 Midpoint Ellipse Algorithm


                                 Midpoint ellipse algorithm is a technique for drawing ellipses in computer graphics. This
                                 method is customized from Bresenham’s algorithm. The advantage of this modified method is
                                 that single calculation operations are required in the program loops. This leads to simple and
                                 fast execution in all processors.
                                 Let us consider one quarter of an ellipse. The curve is divided into two regions. In region I, the
                                 slope on the curve is greater than –1 while in region II less than –1.
                                                                  y
                                                                              Region I
                                                                   b
                                                                                     dy/dx =–1

                                                                                        Region II
                                                                                    a      x

                                                                                        m =–1



                                 Consider the general equation of an ellipse,
                                           b x  + a y  – a b  = 0
                                                      2 2
                                                 2 2
                                            2 2
                                 In region I (dy/dx > –1),
                                 x is always incremented in each step, i.e. x k  + 1 = x k  + 1.
                                 y k+1  = y k  if E is selected, or y k+1  = y k  – 1 if SE is selected.
                                 In order to make decision between S and SE, a prediction (x k  + 1, y k –½) is set at the middle
                                 between the two candidate pixels. A prediction function Pk can be defined as follows:


















                                                                    Region I
                                                    P k  = f(x k  + 1, y k  – ½)
                                                      = b (x k  + 1)  + a (y k  – ½)  – a b
                                                                             2 2
                                                               2
                                                         2
                                                                         2
                                                                   2
        66                                LOVELY PROFESSIONAL UNIVERSITY
   67   68   69   70   71   72   73   74   75   76   77