Computer Graphics Transformations Notes

Overview of Transformations in Computer Graphics

  • Transformations are operations that alter the position or size of an object in computer graphics.
Shearing and Skewing
  • Shearing:
  • A type of transformation that distorts the shape of an object without affecting parallelism.
  • Key Point: If certain edges of a shape are parallel before shearing, they will remain parallel afterward.
  • Types of Shearing:
    • X-Direction Shearing: Altering x coordinates while keeping y coordinates constant.
    • Y-Direction Shearing: Altering y coordinates while keeping x coordinates constant.
    • Matrix Representation:
    • 2D Shearing Matrix for X-direction:
      [\text{Sh}{x} = \begin{bmatrix} 1 & \text{Sh}{x} & 0 \ 0 & 1 & 0 \ 0 & 0 & 1 \end{bmatrix}]
    • 2D Shearing Matrix for Y-direction:
      [\text{Sh}{y} = \begin{bmatrix} 1 & 0 & 0 \ \text{Sh}{y} & 1 & 0 \ 0 & 0 & 1 \end{bmatrix}]
    • Combined X & Y Shearing:
      [\text{Sh}{xy} = \begin{bmatrix} 1 & \text{Sh}{x} & 0 \ \text{Sh}_{y} & 1 & 0 \ 0 & 0 & 1 \end{bmatrix}]
Scaling
  • Scaling: Involves resizing an object.
  • Types of Scaling Matrices:
    • Uniform Scaling: [S = \begin{bmatrix} S{x} & 0 & 0 \ 0 & S{y} & 0 \ 0 & 0 & 1 \end{bmatrix}]
    • Non-uniform Scaling: different factors for x and y directions.
  • Composite Scaling:
    • Applying multiple scaling operations sequentially leads to a resultant scaling transformation.
    • If you apply scaling with factors (Sx, Sy) on a shape, then apply it again with (S{x2}, S{y2}), the overall transformation can be represented as:
      [M{result} = S(S{x}, S{y}) \times S(S{x2}, S{y2}) \times M{original}]
Translation
  • Translation: Moving an object by a certain distance in the x and y directions.
  • Translation Matrix for translation (5 units in x and 6 units in y):
    [T = \begin{bmatrix} 1 & 0 & 0 \ 0 & 1 & 0 \ 5 & 6 & 1 \end{bmatrix}]
Reflection
  • Reflection: Flipping an object over a specified axis.
  • Reflection Matrices:
    • About x-axis:
      [R_{x} = \begin{bmatrix} 1 & 0 & 0 \ 0 & -1 & 0 \ 0 & 0 & 1 \end{bmatrix}]
    • About y-axis:
      [R_{y} = \begin{bmatrix} -1 & 0 & 0 \ 0 & 1 & 0 \ 0 & 0 & 1 \end{bmatrix}]
    • About the line y=x:
      [R_{y=x} = \begin{bmatrix} 0 & 1 & 0 \ 1 & 0 & 0 \ 0 & 0 & 1 \end{bmatrix}]
Composite Transformations
  • When multiple transformations are applied one after another, it can be referred to as a composite transformation.
  • For example, applying scaling, then translation on an object requires the application of their respective matrices in sequence to obtain the final transformation.
3D Transformations
  • 3D Transformation Matrices include similar operations as in 2D but extend them into three dimensions:
  • Translation Matrix:
    [T{3D} = \begin{bmatrix} 1 & 0 & 0 & T{x} \ 0 & 1 & 0 & T{y} \ 0 & 0 & 1 & T{z} \ 0 & 0 & 0 & 1 \end{bmatrix}]
  • Scaling Matrix:
    [S{3D} = \begin{bmatrix} S{x} & 0 & 0 & 0 \ 0 & S{y} & 0 & 0 \ 0 & 0 & S{z} & 0 \ 0 & 0 & 0 & 1 \end{bmatrix}]
  • Rotation Matrices for rotation around x, y, and z-axes compute transformations in 3D space.
Conclusion
  • Understanding these transformations is crucial for creating, manipulating, and rendering objects in computer graphics. Each transformation affects how objects appear on the screen, allowing artists and developers to create complex visual effects and animations.