Computer Graphics and Animation
CSE 4201
        Transformation
     (Shear and Reflection)
                   Lubna Yasmin Pinky
                   Assistant Professor
                   Dept. of CSE, MBSTU,
                   Santosh, Tangail-1902.
                 Transformations
• Transformation is a process of introducing changes in the
  shape size and orientation of objects.
• Types of Transformation:
      - Rigid Body Transformation
      - Affine Transformation
        Rigid Body Transformations
• Rigid body transformations are the ones which preserve the
  shape and size of the object i.e. magnitude and the angle also.
• Examples:
      - Pure rotations
      - pure reflections
      - Translation
              Affine Transformations
• An affine transformation is any transformation that preserves
  co-linearity (i.e., all points lying on a line initially still lie on a
  line after transformation) and ratios of distances (e.g., the
  midpoint of a line segment remains the midpoint
  after transformation).
• Property of preserving parallelism of lines, but not lengths and
  angles.
• Affine transformations are linear transformations which
  included: translation, scaling, rotation, reflection, and shearing
             Affine Transformations
• Example: A unit cube is rotated by 45 degree anti clockwise
  and is non-uniformly scaled. The result is an affine
  transformation of the unit cube, in which parallelism of lines is
  maintained, but neither angles nor lengths are maintained.
          Reflection Transformation
• Reflection is the mirror image of original object. In other
  words, we can say that it is a rotation operation with 180°.
• In reflection transformation, the size of the object does    not
  change.
• Basically the mirror image of any image for 2D reflection is
  generated with respect to the “Axis of Reflection”. For that we
  need to rotate main object 180 Degrees about the reflection
  axis.
Let us understand from this example-
As this image is reflecting with respect to the Y-axis, the reflection
transformation obviously keeps Y-values same. But one must notice
that, the image “Flips” 180 degrees and the values of X of coordinate
positions as shown figure. And similarly when the image gets reflected
with respect to X-axis. As mentioned in the above Y-axis case, the point
gets reflected with respect to Y-axis and obviously point gets flipped.
                  Types of reflection-
•   Transformation in Computer Graphics Reflection is broadly classified in to
    Two Categories. They are,
         I. Horizontal Reflection II. Vertical Reflection
• I. Horizontal Reflection:
When Image gets flipped across, then the Image reflection is known ` as
  Horizontal Reflection. And here image gets reflected with respect to        the   Y-
  axis.
  •II. Vertical Reflection:
         When Image gets flipped up and down, the reflection is referred as    Vertical
  Reflection. For easy understanding, we are providing detailed image         analysis,
  which show both Horizontal and Vertical       Reflections.
                Types of Reflection
•    Horizontal and vertical reflection includes transformation
    geometry in coordinate plane
        - Reflection over x-axis: T(x,y) = T(x,-y)
        - Reflection over y-axis: T(x,y) = T(-x,y)
        - Reflection over line y: T(x,y) = T(y,x)
• Matrix representation of reflection transformation-
  Computer Graphics Reflection transformation is generally implemented
  with respect to the coordinate axes or its coordinate origin as the scaling
  transformation with t minus (negative) scaling factors.
Reflection with respect to line-
     following figures show reflections with respect to X and
     Y axes, and about the origin respectively.
               Shear Transformation
• A transformation that slants the shape of an object is called the
  shear transformation.
• There are two shear transformations X-Shear and Y-Shear.
  One shifts X coordinates values and other shifts Y coordinate
  values.
• However; in both the cases only one coordinate changes its
  coordinates and other preserves its values. Shearing is also
  termed as Skewing.
                            X- Shearing
• X-Shear preserves the Y coordinate and changes are made
  to X coordinates.
• X Sh =       1       0       X’= X+ (Shx * Y)
              Shx      1
                                   Y’=Y
  •   Here,
              Sh x  cotθ
                         Y- Shearing
• Y-Shear preserves the X coordinate and changes are made
  to Y coordinates.
• Y Sh =    1      ShY       Y’=Y+ (ShY * X)
            0      1
                                   X’=X
• Here,
           Shy  cotθ
               X-Y - Shearing
• Here, both co – ordinates changes.
• XY Sh =    1 Shy     Y’=Y+ (ShY * X)
            Shx 1      X’=X+ (ShX * Y)
 Basic 2D Geometric Transformations
• Translation
   – x  x  tx
   – y  y  ty
• Scale
   – x  x  sx
   – y  y  sy
• Rotation
   – x  x  cosθ - y  sinθ
   – y  x  sinθ  y  cosθ
• Shear
   – x  x  shx  y
   – y  y  shy  x
            Inverse Transformations
•Transformations can easily be reversed using inverse
transformations
        1 0  tx
     1          
    T  0 1  ty                        1         
                                          s    0 0
        0 0 1                          x        
                                                1 
                                   S 1   0      0
         cos sin  0                        sy 
                                        0    0 1
    R   sin  cos 0
     1
                                                    
         0                                        
                   0 1
     Basic 2D Inverse Coordinate
           Transformations
  x  x  tx
  y  y  ty
x  x  (1 / sx)
y  y  (1 / sy)
 x   x  cosθ  y  sinθ
 y   x  sinθ  y  cosθ
Thank You