Page 153 - DCAP504_Computer Graphics
P. 153

Computer Graphics



                          Polygons clip against convex clipping windows in the Sutherland-Hodgeman  polygon clipping
                          algorithm. It does so by clipping the subject polygon  against each clip edge, thereby creating
                          intermediate subject polygons. The Sutherland-Hodgeman algorithm can easily extend to three
                          dimensions.
                          Disadvantages of Sutherland-Hodgeman Algorithm

                          Some of the disadvantages of Sutherland-Hodgeman algorithm are as follows:
                          1.   Sutherland-Hodgeman algorithm constantly generates a single output polygon even though the
                              clipped polygon is concave and is expected to produce multiple polygons.
                          2.   The polygons are linked with overlapping segments along the edge of the clipping rectangle. The
                              result may not be desired because it depends on the application.
                          Weiler-Atherton Algorithm
                          The Weiler-Atherton algorithm can clip a concave polygon. The clipping region is called as clip polygon
                          and the polygon to be clipped is referred to as subject polygon. In this algorithm, you have an arbitrary
                          vertex of the subject polygon. You need to trace around its border in the clockwise direction until you
                          find an intersection with the clip polygon. While tracing, you need to:
                          1. Record the intersection point when the edge enters the clip polygon. Continue to trace the subject
                          polygon.
                          2. Record the intersection point when the edge leaves the clip polygon. Make a right turn to follow the
                          clip polygon. You need to consider the clip polygon as subject polygon and vice versa and then proceed
                          as before.
                          When the path of traversal forms a sub-polygon, you output the sub-polygon as a part of the overall
                          result. You need to  continue  tracing the rest of the subject polygon from the intersection point that
                          marks the beginning of an untraced edge. When the entire border of the subject polygon can be traced
                          once then the algorithm terminates.
                          The Weiler-Atherton algorithm is mainly used in modeling to find the union, intersection and
                          difference of the polygons. Consider two polygons M and N with the vertices as shown in the figure
                          10.5.

                                                    Figure 10.5: Weiler-Atherton Algorithm































                          146                     LOVELY PROFESSIONAL UNIVERSITY
   148   149   150   151   152   153   154   155   156   157   158