Page 140 - DCAP504_Computer Graphics
P. 140

Unit 9: Clipping I



               In figure 9.3, the above three categories are clearly differentiated.

                                               Figure 9.3: Line Categories































               In figure 9.3, the line LM falls under category 1 (Visible). The lines OP and QR fall under category 2
               (Invisible) and the lines ST and AB fall under category 3 (Clipping candidate).
               The Cohen Sutherland algorithm provides an efficient way to determine the  category of a line. The
               algorithm divides the procedure into two steps:
               1.   Step 1:  A 4-bit binary code  called region code is  assigned to each endpoint of the line. The
                    endpoints lie in any of the nine regions of the plane.  Figure 9.4 shows the 4-bit region codes that
                    are assigned to every endpoint of the line depending on its position in 2-D space.

                                                Figure 9.4 : Region Codes


















               Each bit of the code is set either true (1) or false (0) according to the following scheme.





                                        LOVELY PROFESSIONAL UNIVERSITY                          133
   135   136   137   138   139   140   141   142   143   144   145