Page 163 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 163

Unit 10: Shearing



            This is illustrated by Figure 10.3.                                                   Notes

                                 Figure 10.3: The Z-shear Transformation





















            This transform can be implemented by the following 4 × 4 matrix:
                                                        
                                                u
                                     È 1 000˘ È ˘   È    u    ˘
                                                
                                     Í 01 00  ˙ Í ˙  Í   v   ˙
                                                v
                                     Í        ˙ Í ˙  =  Í        ˙
                                                 
                                     Í ab  10˙ Í ˙  Í au + v +  w˙
                                                w
                                                         bv
                                     Í        ˙ Í ˙  Í        ˙
                                                O
                                     Î 000 1  ˚ Î ˚  Î   O    ˚
            and so we define the z-shear transformation by
                                   È 1 000˘
                                   Í 01 00  ˙
                             H z;a,b  =   Í  ˙
                                   Í ab  10˙
                                   Í        ˙
                                   Î 000 1  ˚
            If this transformation is applied to the point (u, v, w), we obtain
                                       È 1 000˘
                                       Í 01 00   ˙
                            [u  v  w  1]  Í      ˙   = [v + aw  v  bw + w  1]
                                       Í ab  10˙
                                       Í         ˙
                                       Î 000 1   ˚
            and thus objects can be sheared by applying this matrix to all points of the object.
            10.1.4 2D Transformations

            To write a C program to perform 2D transformations such as shearing Algorithm:
              (a)  Input the shearing factors shx and shy.
              (b)  Shearing related to x axis: Transform coordinates x 1 =x+shx*y and y 1 =y.

              (c)  Shearing related to y axis: Transform coordinates x 1 =x and y 1 =y+shy*x.
              (d)  Input the x ref and y ref values.
              (e)  X axis shear related to the reference line y–y ref is:

                x 1  = x + shx(y – y ref) and y 1  = y.
              (f)  Y axis shear related to the reference line x = x ref is x 1  = x and
              (g)  Display the object after shearing.




                                             LOVELY PROFESSIONAL UNIVERSITY                                   157
   158   159   160   161   162   163   164   165   166   167   168