Content
- Inverse Rotations
- Scaling, Shearing, and Reflection
- Homogeneous Coordinates
Graphics 1 CMP-5010B
Dr. David Greenwood
February, 2022
\[R^{-1}\]
We commonly need to compute the inverse of a rotation, for example, in the hierarchical transformations in character animation skeletons.
\[ \begin{aligned} v' &= R v \\ v &= R^{-1} v' \end{aligned} \]
Where \(R\) is the rotation matrix and \(v\) is a vertex.
Rotation matrices are square.
The determinant of a rotation matrix is 1.
Rotation matrices are orthonormal.
\[ R^TR = I,~ ~RR^T = I \]
Where \(I\) is the identity matrix.
We can use all these properties to test if a matrix is a rotation matrix.
Therefore the inverse of a rotation matrix is the transpose of the rotation matrix.
\[ R^{-1} = R^T \]
Therefore the inverse of a rotation matrix is the transpose of the rotation matrix.
\[ \begin{bmatrix} \cos \alpha &-\sin \alpha \\ \sin \alpha &~\cos \alpha \end{bmatrix}^{-1} = \begin{bmatrix} \cos \alpha &-\sin \alpha \\ \sin \alpha &~\cos \alpha \end{bmatrix}^T = \begin{bmatrix} ~\cos \alpha &\sin \alpha \\ -\sin \alpha &\cos \alpha \end{bmatrix} \]
for Affine transformations
We can separate scaling to uniform scaling and non-uniform scaling.
\[ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix}s~ ~0 \\ 0~ ~s \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} \]
In the example, notice that all vertices are scaled equally by 2.
\[ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix}s_x~ ~0 \\ 0~ ~s_y \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} \]
In the non-uniform example, notice that all vertices are scaled in the \(y\) direction by 2 and in the \(x\) direction by 1, so there is no change in \(x\).
Uniform scaling is a special case of non-uniform scaling where: \[s_x = s_y\]
Shearing is an operation that moves vertices parallel to an axis, scaled by the distance from that axis.
To shear parallel to the \(x\) axis:
\[ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} 1~ ~\lambda \\ 0~ ~1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} \]
To shear parallel to the \(y\) axis:
\[ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} 1~ ~0 \\ \lambda~ ~1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} \]
Reflection is an operation that imposes symmetry across an axis.
To reflect across the \(y\) axis:
\[ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} -1& 0 \\ ~ ~0& 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} \]
To reflect across the \(x\) axis:
\[ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} 1& \hfill 0 \\ 0& \hfill -1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} \]
To reflect across the \(x=y\) axis:
\[ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} 0& ~1 \\ 1& ~0 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} \]
adjective: “of the same kind; alike.”
The homogeneous coordinates relate to our 2D coordinates as follows:
\[ x_h = \frac{x}{w}~, ~y_h = \frac{y}{w}~, ~w \]
Thus: \(x = w x_h\), \(y = w y_h\).
For a general transformation operation, we extend the matrix multiplication we have seen so far, to include the \(w\) coordinate:
\[ \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} a~ ~b~ ~c~ \\ d~ ~e~ ~f~ \\ 0~ ~0~ ~1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} \]
For our homogeneous 3 x 3 transformation matrix, rotation is now:
\[ \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} \cos \alpha& -\sin \alpha& ~0 \\ \sin \alpha& \hfill \cos \alpha& ~0 \\ 0& 0& ~1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} \]
Remains a true rotation matrix.
\[ \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} \cos \alpha& -\sin \alpha& ~0 \\ \sin \alpha& \hfill \cos \alpha& ~0 \\ 0& 0& ~1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} \]
For our homogeneous 3 x 3 transformation matrix, scaling is now:
\[ \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} s_x& ~0& ~0 \\ 0 & ~s_y& ~0 \\ 0 & ~0 & ~1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} \]
For our homogeneous 3 x 3 transformation matrix, generally, the 2 x 2 matrix of the 2D elementary operations occupies the top left corner:
\[ \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} a & ~b& ~0 \\ c & ~d& ~0 \\ 0 & ~0 & ~1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} \]
How do we fit a translation into our 3 x 3 matrix?
\[ \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} 1 & ~0& ~t_x \\ 0 & ~1& ~t_y \\ 0 & ~0& ~1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} \]
Reading: