Geometric Operations

Homogeneous Point

Homogeneous coordinates are used to support translation.

\[\begin{split}P = \begin{bmatrix} x & y & z & 1 \end{bmatrix}\end{split}\]

If the fourth component is not 1, the point can be normalized:

\[\begin{split}\begin{bmatrix} x & y & z & w \end{bmatrix} \to \begin{bmatrix} x \over w & y \over w & z \over w & 1 \end{bmatrix}\end{split}\]

Translation

\[\begin{split}T(x, y, z) = \begin{bmatrix} 1 & 0 & 0 & x \\ 0 & 1 & 0 & y \\ 0 & 0 & 1 & z \\ 0 & 0 & 0 & 1 \\ \end{bmatrix}\end{split}\]

Rotation

\[\begin{split}R_x(\theta) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos(\theta) & \sin(\theta) & 0 \\ 0 & -\sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 0 & 1 \\ \end{bmatrix}\end{split}\]\[\begin{split}R_y(\theta) = \begin{bmatrix} \cos(\theta) & 0 & -\sin(\theta) & 0 \\ 0 & 1 & 0 & 0 \\ \sin(\theta) & 0 & \cos(\theta) & 0 \\ 0 & 0 & 0 & 1 \\ \end{bmatrix}\end{split}\]\[\begin{split}R_z(\theta) = \begin{bmatrix} \cos(\theta) & \sin(\theta) & 0 & 0 \\ -\sin(\theta) & \cos(\theta) & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{bmatrix}\end{split}\]

Scaling

\[\begin{split}S(x, y, z) = \begin{bmatrix} x & 0 & 0 & 0 \\ 0 & y & 0 & 0 \\ 0 & 0 & z & 0 \\ 0 & 0 & 0 & 1 \\ \end{bmatrix}\end{split}\]

Transforming Normals

Normals cannot be transformed like normal vectors. Transpose of the inverse of a transformation matrix must be used to transform normals:

\[N' = N * M^{-1T}\]

Coordinate Systems

Vector Left-handed Right-handed
Right x x
Forward y -z
Up z y