Transformation Matrices

Prerequisites

Matrices Show

Matrix Transposition Show

Row And Column Vectors Show

Pythagorean Theorem Show

Dot product of row and column vectors Show

Vectors Show

Position Vectors Show

Matrix Multiplication Show

Elements In A Matrix Show

Transformation Matrices

Introduction

  • In previous articles we have seen that we can multiply two matrices together to produce a third matrix.
  • We have also seen that a vector is a special kind of matrix with only one row or column.
  • A transformation matrix is a matrix that can be used to multiply a vector to produce a vector of the same size.
  • By choosing the values in our matrix we can control how the vector is transformed.

Example

  • Let's start with the 2-dimensional vector:
  • If we multiply it by a 2x2 matrix then we will get a vector which is also 2-dimensional:
  • By choosing different values for our matrix we can transform the vector in different ways.

Identity Matrix

  • If we choose an identity matrix as our transformation matrix then the output will equal the original vector:

Scaling Matrix

  • If we want to scale a vector then we can multiply each component by a number:

Shearing Matrix

  • Sometimes we want to slant our object:
  • In this example, the slant is parallel to the x axis:
    • x is offset by a function of y (the offset gets larger as y grows).
    • y remains unchanged.
    >

Rotation Matrix

  • To rotate a point anti-clockwise around the origin we use the following equation:
  • This can be converted to a matrix transformation:
  • If we want to perform a clockwise rotation then we negate the matrix: hint:

Translation Matrix

  • Unfortunately it isn't possible define a matrix that translates a vector such as:
  • However, if we extend our vector by 1 dimension: and extend our transformation matrix by 1 row and 1 column: Then our new vector will be:
  • We can use the new e and f parameters of our matrix to translate our vector:

Affine Transformations

  • As part of our definition of a translation matrix we:
    • Extended the vector by 1 dimension
      • This converted it from a euclidean coordinate into a homogeneous coordinate.
    • Extended the transformation matrix by 1 row and 1 column
      • This converted it from a linear transformation into an affine transformation.
  • Each of our transformations can be rewritten as affine transformations:
    • Identity:
    • Scaling:
    • Shearing:
    • Rotation (anti-clockwise):
    • Translation:

Combining Transformations

  • The true power of transformation matrices comes from their ability to be conbined.
  • For example, if we want to translate and scale a vector then we can use:
  • Or more generally, two transformation matrices can be combined into one by multiplying them:

Order of Transformations

  • If we define a scaling matrix as:
  • and a translation matrix as:
  • then we can combine them in two different ways:
    • The translation first, and then the scaling:
    • The scale first, and then the translation (in scaled space):
    • The order of the translations goes from right to left:
      • if we have a transformation: T1T2T3
      • T3 would be applied first, then T2, and finally T1.

Extending to 3D

  • Extending to 3D is a simple case of defining a 4D vector:
  • And a 4D transformation matrix:
  • We can redefine each of our 2D transformations in 3D form:
    • Identity:
    • Scaling:
    • Shearing:
    • Rotation (around each axis):
    • Translation: