Page 79 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 79

Unit 5: Implementing Ellipse Algorithm



            5.3.3 Ellipse Segment                                                                 Notes
            Area For the overall goal of determining overlap areas between ellipses and other curves, a
            useful measure is the area of an ellipse segment. A secant line drawn between two points on
            an ellipse partitions the ellipse area into two fractions, as shown in Figure 5.1 and Figure 5.2.
            An ellipse segment is the area confined by the secant line and the portion of the ellipse from
            the  first  point  (x 1 , y 1 ) to the second point (x 2 , y 2 ) traversed in a counter-clockwise direction.
            The segment’s complement is the second of the two areas demarcated by the secant line. For
            the ellipse shown in Figure 5.1, the segment area defined by the secant line through the points
            (x 1 , y 1 ) and(x 2 , y 2 ) is the area of the sector minus the area of a triangle defined by the two points
            and the ellipse centre (at the origin). The coordinates for the triangle’s vertices are known, i.e.,
            as (x 1 , y 1 ), (x 2 , y 2 ) and (0, 0), and the triangle area can be found by:

                                   1
                                             ◊
                                       ◊
            Triangle Area        =   ◊|xy  - xy  |                                   (5)
                                   2  1  2  2  1
            For the case depicted in Figure 5.1, subtracting the triangle area (Equation (5)) from the area of
            the ellipse sector (Equation (4)) gives the area between the secant line and the ellipse, i.e., the
            area of the ellipse segment counter-clockwise from (x 1 , y 1 ) to (x 2 , y 2 ).
            For the ellipse of Figure 5.2, the area of the segment shown is the sector area plus the area of
            the triangle. The key difference between the cases in Figure 5.1 and Figure 5.2 that requires the
            area of the triangle to be either subtracted from, or added to, the sector area is the size of the
            integration angle. If the integration angle is less than , then the triangle area must be subtracted
            from the sector area to give the segment area. If the integration angle is greater than , the
            triangle area must be added to the sector area.

                                   (q - q  ) ◊AB  1
                                                  ◊
                                                       ◊
                     Segment Area =   2  1  ±  | ◊ xy 2  - xy 1 |                    (6)
                                                 1
                                                      2
                                       2     2
            A robust algorithm for determining the area of an ellipse segment is achieved through a
            generalization of the cases illustrated in Figure 5.1, Figure 5.2 and Equation (6). For an ellipse
            that is centred at the origin with its axes parallel to the coordinate axes, the segment area is
            demarcated by a secant line and the ellipse proceeding counter-clockwise from a first given
            point (x 1 , y 1 ) to a second given point (x 2 , y 2 ). The ellipse is defined by specifying its semi-axes
            lengths, A > 0 and B > 0. The points are passed to the algorithm as (x 1 , y 1 ) and (x 2 , y 2 ), both of
            which must be on the ellipse. The ELLIPSE_SEGMENT algorithm is outlined in Equation (7).
                                 A
                       Ï arccos(x  /)  , y ≥ 0
               1.     θ 1  =  Ì  1       1                                          (7a)
                         p
                                     A
                       Ó 2 -  arccos(x 1  /), y <  0
                                         1
                                 A
                       Ï arccos(x  /)  , y ≥  0
                   θ 2  =  Ì   2         2
                                     A
                         p
                       Ó 2 - arccos(x 2  /), y <  0
                                         2
                       Ï q ,  q < q
               2.     θ 1  =  Ì  1  1  2                                            (7b)
                       Ó q -  2 p q,  1  >  q 2
                         1
                                          
                       (q -  q  ) ◊AB  sign (q -  q -  ) p
               3.   Area =   2  1  +    2   1    | ◊ xy  - xy  |                     (7c)
                                                    ◊
                                                          ◊
                            2            2         1  2  2  1
                                                     x 2  y 2
            Where the ellipse implicit polynomial equation is   +   = 1
                                                     A 2  B 2
               A > 0  is the semi-axis length along the x-axis
               B > 0  is the semi-axis length along the y-axis
              (x 1 , y 1 )  is the first given point on the ellipse
              (x 2 , y 2 )  is the second given point on the ellipse
            θ 1  and θ 2  are the parametric angles corresponding to the points (x 1 , y 1 ) and (x 2 , y 2 )
                                             LOVELY PROFESSIONAL UNIVERSITY                                    73
   74   75   76   77   78   79   80   81   82   83   84