Page 173 - DCAP504_Computer Graphics
P. 173

Computer Graphics



                          Back face
                          This algorithm is based on the inside test. Let us consider an object say a cube. Any object in computer
                          graphics is made of polygons or surfaces. A cube is made of six different polygons.
                          Let us make an assumption that if a surface is in the front of the viewer then it is drawn using edge in
                          anticlockwise pen motions whereas the surfaces that are not visible to the viewer are drawn using edge
                          in the clockwise pen motions. A polygon has two surfaces such as the front surface and the rear surface.
                          The front surface of a polygon is drawn using the edge in anticlockwise direction and the rear surface is
                          drawn using the edge in clockwise direction.

                          This brings us to a conclusion that only those surfaces or portions of the object are visible which are
                          drawn in anticlockwise direction. There is a very simple test for checking whether a surface is in front of
                          the user’s view or not. Take a normal vector passing through a surface and if that vector comes to the
                          viewer’s eye then the surface is visible to the viewer which otherwise is hidden. That is whether it is in
                          the front side or in the rear side. However, the most important question that arises here is how to find
                          out the direction of any vector.
                          Let us find the solution to this problem. Take two vectors A and B in a right-handed system. The dot
                          product of these two vectors can be written as:
                                                                    A· B = │A││B│cos θ                           …. (Equation 11.2)

                          where,
                          Both│A│and│B│are length of vectors A and B respectively. Therefore they are non-negative values.
                          Therefore, the sign of dot product is based on cos θ.

                          If the two vectors are in the same direction, then
                                          0 ≤ θ ≤ ∏/2

                          If the two vectors are in the opposite direction, then
                                          ∏/2 < θ ≤ ∏
                           We know that
                                              cos θ  > 0                       if  0 ≤ θ <  ∏/2
                                              cos θ < 0                        if  ∏/2 < θ ≤ ∏
                          This means,
                                              A · B = │A││B│cos θ > 0               if 0 ≤ θ < ∏/2
                          and              A · B = │A││B│cos θ < 0               if  ∏/2 < θ ≤ ∏

                          Also,            if A · B > 0            A and B are in the same direction
                          and              if  A · B < 0            A and B are in the opposite directions
                          On the basis of this, if we take two vectors such as vector N which is normal to the surface in test and
                          vector V which is the direction vector, then
                          If                                   N · V > 0          surface in test is visible

                          and                                N · V < 0          surface is invisible                        …. (Equation 11.3)
                          If it is considered that the vector V is in the direction of depth, that is, in the direction of Z-axis then V =
                          [0 0 V3].
                          Therefore,
                                                          V · N = [0 0 V3] · [N1 N2 N3]

                                                                    = V3N3                                                                                                        … (11.4)




                          166                     LOVELY PROFESSIONAL UNIVERSITY
   168   169   170   171   172   173   174   175   176   177   178