Geometric Transformations Part III

Matrix representation of 3D transformations

As discussed in the previous tutorial, a 3 x 3 matrix defines a 2D transformation through the use of homogeneous coordinates. In a similar manner 3D transformations can be described though 4 x 4 matrices which is the topic of the current tutorial (and last part of the “Geometric Transformations” series).

From 3 x 3 to 4 x 4
In order to represent 3D transformations as 4 x 4 matrices the points undergoing the transformations have to be expresses as (x, y, z, W) instead of (x, y, z). Two of these quadruples represent the same point if one is a nonzero multiple of the other.

Most of the rules that apply to 2D transformations still hold: the point (x, y, z, W) with W ≠ 0 is represented as (x/W, y/W, z/W, 1), and a quadruple of type (0, 0, 0, 0) is not permitted.

In 3D space each point is represented as a line through the origin in 4-space. The homogeneous representation of each of the points forms a 3D subspace of 4-space compressed in the equation W = 1.

Figure 1. Table of conventions for axis transformation via counterclockwise rotation.

Figure 1. Table of conventions for axis transformation via counterclockwise rotation.

Throughout the geometric transformation tutorials we are using the right-handed 3D coordinate system. This is due to simplicity – a 90 degree counterclockwise rotation in such a system will transform one positive axis into another according to the table in Fig. 1.

Other materials will use the left-handed system due to the system offering a natural approach to understanding values on the Z axis (larger values are further from the viewer). The positive rotations allow the same type of matrix to be used interchangeably in order to express a left-handed and a right-handed system.

3D transformation matrices

When using matrix compositing it can be desirable to incorporate a matrix which does not affect a specific outcome. This would be an identity matrix such as the one described in Fig. 2. It’s worth noting that in OpenGL when using only an identity matrix for (model and projection)  transformations the viewport will be looking down the negative Z axis.


Figure 2. Identity matrix. a) Original point P, point after identity matrix was applied P’, and the contents of identity matrix I. b) Expression encompassing multiplication by the identity matrix.


Using the information from the previous tutorial on 2D transformations, the translation transformation in 3D can be rewritten by extending the 2D affine translation as illustrated in Fig. 3. As seen before, the translation matrix properties did not change: there’s a value of 1 on the main diagonal, and a translation component down the last column.

Figure 3.

Figure 3. Translation matrix. a) Original point P, translated point P’, translation matrix T. b) Translation expression of point P to P’.

The 3D scaling transformation is also expressed by extending the 2D scaling matrix form (Fig. 4).

Figure 4.

Figure 4. Scaling matrix. a) Original point P, newly scaled point P’, scaling matrix S with scaling factors. b) Scaling expression.

The rotation illustrated in the previous tutorial can be extended to express a 3D rotation around the Z axis as seen in Fig. 5 c.


Figure 5. Rotation matrices. a) Rotation around the X axis. b) Rotation around the Y axis. c) Rotation around the Z axis.

Compositing 3D transformation matrices

Compositing 3D transformation matrices follows the same rules discussed in the previous chapter for 2D transformations. It is important to note that the order of transformation matrix multiplication matters in order to get the final desired position, aspect, and orientation of a vertices.

As illustrated in Fig. 6 a rotation matrix multiplied by a translation matrix will not produce the same result as a translation followed by a rotation (the orientation of the object is correct, however it’s location in case A differs from the one in case B).

Figure 6.

Figure 6. 3D transformation matrix compositing.

So far we have transformed points belonging to objects in the same coordinate system. The advantage to this approach is that the coordinate system remains unaltered, the objects being transformed in relation to the origin of the system. This approach has its benefits, however there is an alternative method: changing the coordinate system.

The second approach is particularly useful when combining objects where each one is defined in its own coordinate system.

This was the final part of the Geometric Transformations tutorial series, and hopefully it provided a strong foundation of the mathematical concepts used in computer graphics and in specific by the OpenGL pipeline.

The next tutorials will cover the different types of matrices used to convert from one coordinate system to another – model, view, and projection matrices.

Software engineer (computer graphics) & CS PhD Padawan. Interested in game engine dev, GLSL, computer vision, GPGPU, V.E./V.R, algo challenges, & Raspberry Pi dev. When I don't shift bits, I enjoy playing SC2, driving to new places, drawing, and playing guitar.

blog comments powered by Disqus