transform

  • Modeling
  • View transformation (Viewing)

The 2 d transformation

The zoom


[ x y ] = [ s x 0 0 s y ] [ x y ] \begin{bmatrix} x’ \\ y’ \end{bmatrix} = \begin{bmatrix} s_x & 0 \\ 0 & s_y \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}

Reflection (symmetry)


[ x y ] = [ 1 0 0 1 ] [ x y ] \begin{bmatrix} x’ \\ y’ \end{bmatrix} = \begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}

shear

The y-coordinate stays the same, the level changes


[ x y ] = [ 1 a 0 1 ] [ x y ] \begin{bmatrix} x’ \\ y’ \end{bmatrix} = \begin{bmatrix} 1 & a \\ 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}

rotating

By default, it rotates around (0, 0), counterclockwise


R Theta. = [ c o s Theta. s i n Theta. s i n Theta. c o s Theta. ] R_\theta = \begin{bmatrix} cos_{\theta} & -sin_{\theta} \\ sin_{\theta} & cos_{\theta} \end{bmatrix}

Linear transformation

Homogeneous coordinates

Why do we need homogeneous coordinates?

Translational transform


x = x + t x y = y + t y x’ = x + t_x \\ y’ = y + t_y

Translation cannot be expressed in matrix form


[ x y ] = [ a b c d ] [ x y ] + [ t x t y ] \begin{bmatrix} x’ \\ y’ \end{bmatrix} = \begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} + \begin{bmatrix} t_x \\ t_y \end{bmatrix}

Translation is not a linear transformation

Add a dimension


  • 2 D   p o i n t = ( x . y . 1 ) T 2D\ point = (x, y, 1)^T

  • 2 D   v e c t o r = ( x . y . 0 ) T 2D\ vector = (x, y, 0)^T

Translation matrix representation


( x y w ) = ( 1 0 t x 0 1 t y 0 0 1 ) ( x y 1 ) = ( x + t x y + t y 1 ) \begin{pmatrix} x’ \\ y’ \\ w’ \end{pmatrix} = \begin{pmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{pmatrix} \cdot \begin{pmatrix} x \\ y \\ 1 \end{pmatrix} = \begin{pmatrix} x + t_x \\ y + t_y \\ 1 \end{pmatrix}

Affine Transformations

Affine map = linear map + translation


( x y ) = ( a b c d ) ( x y ) + ( t x t y ) \begin{pmatrix} x’ \\ y’ \end{pmatrix} = \begin{pmatrix} a & b \\ c & d \end{pmatrix} \cdot \begin{pmatrix} x \\ y \end{pmatrix} + \begin{pmatrix} t_x \\ t_y \end{pmatrix}

Use homogeneous coordinates


( x y 1 ) = ( a b t x c d t y 0 0 1 ) ( x y 1 ) \begin{pmatrix} x’ \\ y’ \\ 1 \end{pmatrix} = \begin{pmatrix} a & b & t_x \\ c & d & t_y \\ 0 & 0 & 1 \end{pmatrix} \cdot \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}

Inverse transformation


M 1 M^{-1}

Combination of transformation

A complex transformation can consist of multiple simple transformations, the order of which is crucial (matrices do not satisfy commutative laws).

Transform decomposition

3 d transform

Homogeneous coordinates

  • 3D point =
    ( x , y , z , 1 ) T (x, y, z, 1)^T
  • 3D vector =
    ( x , y , z , 0 ) T (x, y, z, 0)^T

Matrix representation


( x y z 1 ) = ( a b c t x d e f t y g h i t z 0 0 0 1 ) ( x y z 1 ) \begin{pmatrix} x’ \\ y’ \\ z’ \\ 1 \end{pmatrix} = \begin{pmatrix} a & b & c & t_x \\ d & e & f & t_y \\ g & h & i & t_z \\ 0 & 0 & 0 & 1 \end{pmatrix} \cdot \begin{pmatrix} x \\ y \\ z \\ 1 \end{pmatrix}

Yan Lingqi < introduction to Modern Computer Graphics >>