Page 79 - DCAP504_Computer Graphics
P. 79

Computer Graphics



                          The figure 6.6 depicts the rotation of a point coordinate.

                                                    Figure 6.6: Rotation of a Point Coordinate























                          The rotation matrix to rotate the object by an angle θ counterclockwise is given by:
                                cos θ  −sin   θ
                          R ( θ)  =      
                                           
                                  sin θ  cos θ  
                          Multiply all the point coordinates (point coordinate matrices) of the object with the rotation matrix to
                          rotate the object by an angle θ . The following is the matrix multiplication of rotation matrix R ( θ ) and
                          point coordinate matrix (P) to obtain the rotated point coordinate matrix (P’).
                              R
                            ' P = ( θ) ⋅P
                             ' x  cos θ  − sin    θ  x 
                               =           
                            ' y     sin  θ  cos θ     y 
                             ' x   ⋅ cosx  θ − y  ⋅sin   θ
                               =          ………………………….. (Eq.6.2)
                            ' y     x ⋅sin θ + y ⋅ cos θ 

                          The equation 6.2 is used to calculate the coordinates of the object that is to be rotated counterclockwise
                          by an angleθ . All the coordinates of the object have to be multiplied with the rotation matrix and the
                          rotated coordinates of the original object is calculated.  Similarly, we can rotate the object clockwise. The
                          equation 6.3 is used to rotate the object by an angle  θ  clockwise.
                             ' x   x ⋅ cos θ  + y ⋅sin θ  
                               =         ………………………….... (Eq.6.3)
                                              
                            ' y     − x  ⋅sin θ + y ⋅ cos θ 

                                             A triangle object is to be rotated counterclockwise by an angle 90 degree, with
                                             reference to the origin of the 2-D space. The triangle object has three point

                                             coordinates (0, 0), (2, 0), and (1, 2). Using the equation 6.2, the point coordinate
                                             values of the triangle are calculated. The point coordinate values of the triangle
                                             after rotating it by an angle 90 degree are (0, 0), (0, 2), and (-2, 1). The object is
                                             rotated clockwise by using the equation  6.3. The coordinates of the object
                                             rotated clockwise are (0, 0), (0, -2), and (-1, 2).








                          72                      LOVELY PROFESSIONAL UNIVERSITY
   74   75   76   77   78   79   80   81   82   83   84