Page 150 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 150

Lab on Computer Graphics



                   Notes         So a 4×4 matrix implements a frame to frame transformation for translated frames, and any
                                 matrix of this type (for arbitrary a, b, c) will translate the frame F. We call any matrix

                                                                     È 1 000˘
                                                                     Í 01 00  ˙
                                                               T a,b,c  =  Í  ˙
                                                                     Í 00 10˙
                                                                     Í        ˙
                                                                     Î ab c  1 ˚
                                 A translation matrix and utilize matrices of this type to implement translations.
                                 Transformation Directly to the Coordinates of Point
                                                  
                                                      , )
                                 Given a frame F = (, ,uv wo  and a point P that has coordinates (u, v, w) in F, if we apply the
                                 transformation to the coordinates of the point we obtain
                                                           È 1 000˘
                                                           Í 01 00  ˙
                                                   [u v w 1] Í      ˙  = [u + a  v + b  w + c  1]
                                                           Í 00 10˙
                                                           Í        ˙
                                                           Î ab c  1 ˚
                                 That is, we can translate the point within the frame F. An illustration of this is shown in Figure 9.1


                                                           Figure 9.1: Translating a Point
















                                 Translation is a simple transformation that is calculated directly from the conversion matrix for
                                 two frames, one a translate of the other. The translation matrix is most frequently applied to
                                 all points of an object in a local coordinate system resulting in an action that moves the object
                                 within this system.
                                           #include<stdio.h>
                                           #include<string.h>
                                           #include<alloc.h>
                                           #include<graphics.h>
                                           #include<stdlib.h>
                                           #include<conio.h>
                                           #include<bios.h>
                                           #include<math.h>
                                           #include<dos.h>
                                           #defineLTARROW0x4B
                                           #defineRTARROW0x4D
                                           #defineUPARROW0x48
                                           #defineDNARROW0x50
                                           #defineCR0x0d


        144                               LOVELY PROFESSIONAL UNIVERSITY
   145   146   147   148   149   150   151   152   153   154   155