Page 152 - DCAP504_Computer Graphics
P. 152

Unit 10: Clipping II



               The figure 10.3 below depicts a general idea about Sutherland-Hodgeman clipping algorithm.

                                             Figure 10.3: Sutherland-Hodgeman
                                                      Algorithm













               A single polygon can be clipped against each edge of the window at a time. In the above figure 10.3, the
               Southerland-Hodgeman algorithm clips around the edges of the clipping rectangle (Clipping window).
               The polygon is clipped against the four clipping edges, one after another. This algorithm does clipping
               by traversing all the edges of the polygon and creates the clipped polygon by following the below four
               rules:
               1.   If both points are inside the clipping window, as in figure 10.4 (a), then add the second one (Pi+1)
                    to the result polygon.
               2.   If the current point is inside the clipping window and the next one lies outside, as in figure 10.4
                    (b), then add the intersection point 'I' to the result polygon.
               3.   If the current point is outside the clipping window and the next one lies inside, as in figure 10.4
                    (c), then add the intersection point 'I' and the next point Pi+1to the result polygon.
               4.   If both points are outside the clipping window, as in figure 10.4 (d), then insert none of them to the
                    result polygon.

                                        Figure 10.4: Divide and Conquer Approach



























               Thus, you get a new polygon (result polygon), which is obtained by clipping 'around' the edges of the
               clipping window.









                                        LOVELY PROFESSIONAL UNIVERSITY                          145
   147   148   149   150   151   152   153   154   155   156   157