Transformation
Matrices
Table of contents
Page | 2
Introduction
3
Dilations
4
Reflections
5
Rotations
6
Translations
8
Combining Transformations
10
Summary
12
Introduction
3D transformations are a fundamental concept in computer graphics and mathematics,
allowing us to manipulate objects in three-dimensional space. These transformations are often
represented using matrices, providing an elegant and efficient way to alter the position,
orientation, and scale of objects. In the realm of 3D coordinates, we can express points using
either the (i, j, k) notation, aligning with the coordinate axes, or the (x, y, z) notation, which
directly corresponds to the Cartesian coordinates. Both notations encapsulate the same spatial
information, but their representation differs.
3D coordinates are stored in a matrix using a column matrix format, either in (i, j, k) or (x, y,
z) notation. To set up and use a transformation matrix, identify the transformation type,
construct the appropriate matrix, and then multiply it with the column matrix representing the
point or object to achieve the desired transformation e.g.
𝒊
[𝐣]
𝐤
For rotation, different transformation matrices are applied to points to achieve rotations
around the x, y, or z-axis. Scaling, or dilation, involves adjusting an object's size while
maintaining its shape, through multiplication with scaling matrices. Reflection flips objects
across specific planes, like mirrors, using reflection matrices. Translation, on the other hand,
shifts objects along the x, y, and z axes, enabled by translation matrices (4x4 or 3x4) e.g.
1
0
[
0
0
0
1
0
0
0
0
1
0
𝑑𝑥
1
𝑑𝑦
] [0
𝑑𝑧
0
1
0
1
0
0
0
1
𝑑𝑥
𝑑𝑦]
𝑑𝑧
For demonstrating these transformations, the triangular prism OABCDE will be used:
0 4 4 0 0 0
[0 0 5 5 5 0 ]
0 0 0 0 3 3
z
3
O
4
y
5
x
Page | 3
Dilations
Matrices can be used to represent dilation along axis x, y, and z using i, j and k vectors, the
scaling factor along a given axis can be denoted as "s" for the dilation. Unit vectors (i, j, k)
can then be constructed, where the i-vector is defined as [s, 0, 0] implying a transformation
along the x axis, the j-vector as [0, 1, 0], and the k-vector as [0, 0, 1]. These unit vectors serve
as the fundamentals for the transformation. Assembling the unit vectors into a 3x3 matrix, for
an x-axis dilation, will have the resulting matrix:
𝑠 0
[0 1
0 0
0
0]
1
Applying this to y-axis and z-axis dilation has the resulting matrices:
1
Y-axis [0
0
0
𝑠
0
0
0]
1
1
Z-axis[0
0
0
1
0
0
0]
𝑠
Applying a dilation of 2 units along the x-axis, 0.5 units along the y-axis, and 3 units along
the z-axis to the triangular prism is given by the following matrix multiplication.
𝑇1 × 𝑀 = 𝑀 ′
2
[0
0
0 0 0
0.5 0] [0
0 3 0
4
0
0
4 0
5 5
0 0
0
5
3
0
0
0 ] = [0
3
0
8
0
0
8
0
2.5 2.5
0
0
z
9
2.5
O
8
x
Page | 4
y
0
2.5
9
0
0]
9
Reflections
The xy, yz, and zx planes are the three main reference planes that make up a threedimensional Cartesian coordinate system. They meet at right angles, the yz plane extends
vertically, the zx plane stretches horizontally, and the xy plane represents the ground or floor
level. In order to determine orientations, carry out transformations, and examine relationships
in 3D space, these planes are essential.
The eight octants that separate 3D space into various regions are equally important. The
positive and negative orientations along each coordinate axis combine to generate these
octants. Octant I contains positive values of x, y, and z; Octant II contains positive x, negative
y, and positive z; Octant III contains negative x, negative y, and positive z; and so on. The
relative positions of points, vectors, and objects within a three-dimensional environment can
be determined efficiently due to these octants.
Operations in 3D space that mirror an object or shape across these reference planes, the xy
plane, yz plane, and zx plane, are called reflection transformations. For example, reflecting
across the xy plane needs a negative z-coordinate while the x and y coordinates are positive.
This action essentially mirrors the object across the xy plane. Consider an object prior to
reflection over the xy plane as above it, then after reflection it will appear below the plane.
The unit vectors for this transformation are [1, 0, 0], [0, 1, 0], and [0, 0, -1] forming the
following 3x3 transformation matrix.
1
[0
0
0 0
1 0]
0 −1
Similarly, a reflection across the zx and yz planes would require the following matrices.
−1
𝑧𝑥 − 𝑝𝑙𝑎𝑛𝑒 [ 0
0
0
1
0
0
1 0 0
0] 𝑦𝑧 − 𝑝𝑙𝑎𝑛𝑒 [0 −1 0]
1
0 0 1
Applying the transformation matrix to the object's vertices performs the reflection across the
zx-plane.
z
-x
-y
5
4
O
-3
1 0
[0 1
0 0
0 0
0 ] [0
−1 0
4
0
0
4 0
5 5
0 0
0
5
3
0
0]
3
y
0 4
= [0 0
0 0
4
5
0
0 0
0
5 5
0]
0 −3 −3
x
-z
Page | 5
Rotations
We can change the orientation of objects in 3D space around the x, y, and z axes by using
rotation matrices. We can accomplish different rotations by building transformation matrices
using the (i, j, k) unit vectors and the relevant trigonometric functions. The sign convention
in these rotation matrices is that counterclockwise rotation is given in positive degrees and
clockwise negative degrees. From this we can build three matrices for rotation around the xaxis, y-axis, and z-axis as follows:
A rotation around the x-axis changes the orientation of an object as if it were being “rolled”.
To achieve this, a rotation matrix can be constructed using the unit vectors (i, j, k) as [1, 0, 0],
[0, cos(θ), -sin(θ)], and [0, sin(θ), cos(θ)], respectively. Here, θ represents the angle of
rotation. By multiplying this matrix with the object's vertices, the entire object rotates around
the x-axis.
1
[0
0
0
cos 𝜃
sin 𝜃
0
− sin 𝜃]
cos 𝜃
A rotation around the y-axis simulates a “yawing” motion, altering the object's orientation as
if it were being turned left or right. The unit vectors for this rotation are [cos(θ), 0, sin(θ)], [0,
1, 0], and [-sin(θ), 0, cos(θ)]. Once again, multiplying the rotation matrix by the object's
vertices facilitates rotation around the y-axis.
[
cos 𝜃
0
− sin 𝜃
0
1
0
sin 𝜃
0 ]
cos 𝜃
A rotation around the z-axis replicates a spinning motion, changing the object's orientation as
if it were being spun. The basis vectors for this rotation are [cos(θ), -sin(θ), 0], [sin(θ), cos(θ),
0], and [0, 0, 1]. By applying the rotation matrix to the object's vertices, the object rotates
around the z-axis.
cos 𝜃
[ sin 𝜃
0
− sin 𝜃
cos 𝜃
0
0
0]
1
From these matrices we can form the following table of rotation matrices:
Clockwise rotation
by 90°
Counterclockwise
rotation by 90°
Rotation by 180°
Page | 6
1
[0
0
1
[0
0
X-axis
0 0
0 1]
−1 0
0 0
0 −1]
1 0
1 0
0
[0 −1 0 ]
0 0 −1
Y-axis
0 0 −1
[0 1 0 ]
1 0 0
0 0 1
[ 0 1 0]
−1 0 0
Z-axis
0 1 0
[−1 0 0]
0 0 1
0 −1 0
[1 0 0 ]
0 0 1
−1
[0
0
−1
[0
0
0 0
1 0]
0 −1
0
−1
0
0
0]
1
To demonstrate these matrices effects on 3D objects we will use OABCDE and rotate it 90°
clockwise around the y-axis.
0
[0
1
0 −1 0 4
1 0 ] [0 0
0 0 0 0
4
5
0
0 0
5 5
0 3
0
0 0
]
[
=
0
0 0
3
0 4
0
5
4
0 −3 −3
5 5
0]
0 0
0
z
-x
4
-3
y
-y
5
-z
x
Page | 7
Translations
For translations we will need to use 3x4 matrices as a 3x3 matrix is unable to represent
translation transformations in a three-dimensional space since it is missing the necessary
components. Translation involves changing an object's position along one or more of the
coordinate axes (x, y, and z), and in order to properly represent such movement, extra
components that are not included in a 3x3 matrix are required.
A 3x3 matrix works with points or vectors that have three x, y, and z components. A 3x3
matrix can shift a 3D point's position, but only if it does so inside the plane bounded by the
three axes, the point cannot be moved along any of the axes.
The translation vector determines the amount by which you want to move the object in 3D
space. This is denoted as (dx, dy, dz), where dx represents the displacement along the x-axis,
dy along the y-axis, and dz along the z-axis. To form the 3x4 matrix we keep the left side as
the 3x3 and simply add to it the right side forming this matrix.
1
[0
0
0
1
0
0
0
1
𝑑𝑥
𝑑𝑦]
𝑑𝑧
In order to use this matrix, we will need to add a fourth row to our column matrix, this forth
row store a 1, this will for the following column matrix.
𝒊
𝒋
[ ]
𝒌
1
For example, to translate the prism OABCDE by 5 units along the y-axis we would have
dy = 5 and the matrix multiplication would be as follows:
1
[0
0
Page | 8
0
1
0
0
0 0
0
0 5] [
0
1 0
1
4
0
0
1
4
5
0
1
0
5
0
1
0
5
3
1
0
0 4
0
] = [5 5
3
0 0
1
4
5
0
0
0 0
10 10 5]
0
3 3
Alternatively, rather than multiplying by a matrix we add a matrix containing the translation.
For the x, y, and z axis we use the following:
𝑥𝑖
𝑂𝑖
𝑂𝑖
𝑋 = [ 𝑂𝑗 ] 𝑦 = [ 𝑦𝑗 ] 𝑧 = [𝑂𝑗 ]
𝑂𝑘
𝑧𝑘
𝑂𝑘
For example, if we wanted to move an object along the y-axis by 5 units, we would add a
matrix [0, 5, 0], Applying this to our triangular prism OABCDE we have the following
matrix transformation:
0
[0
0
4
0
0
4 0
5 5
0 0
0
5
3
0
0
0 ] + [5
3
0
0 0
5 5
0 0
0
5
0
0 0
0
5 5 ] = [5
0 0
0
4 4
5 10
0 0
0
0 0
10 10 5]
0
3 3
-x
z
3
-y
o
5
5
4
y
x
-z
Page | 9
Combining Transformations
To combine transformations, we can multiply them in the opposite order for which we want
them to occur. The order in which you multiply them matters because matrix multiplication is
not commutative, that is that the sequence of transformations can affect the result. The
resulting combined matrix represents the composed transformation.
Multiply the individual transformation matrices in the opposite order in which you want to
apply them. The order of multiplication matters, so if we want to perform transformation A
followed by transformation B, multiply B by A. For example, if we wanted to perform a
dilation by 2 along the y-axis (T1) followed by a reflection over the zx-plane (T2) we would
form the following matrices:
T2 × T1 = T
1 0 0 1
[0 −1 0] [0
0 0 1 0
0
2
0
0
1
0 ] = [0
1
0
0
−2
0
0
0]
1
Applying this to OABCDE
T × M = M’
1
[0
0
0
−2
0
0 0 4
0 ] [0 0
1 0 0
4
5
0
0 0
5 5
0 3
0
0 4
0 ] = [0 0
3
0 0
4
0
−10 −10
0
0
0
0
−10 0]
3
3
z
-x
3
-y
-10
O
4
x
Page | 10
-z
y
Combining our 3x3 transformation matrices with 3x4 translation will not work so in order to
combine these transformations we need to expand our existing transformation matrices into
4x4 matrices with the bottom row and right column as [0, 0, 0, 1] while retaining the original
3x3 matrix in the top left of the 4x4. This will allow for the combination of translation and
rotation, dilation, and/or reflection. If we wanted to rotate our prism counterclockwise by 90°
about the z-axis (T1), then translate it by 2 units along the x-axis (T2):
T2 × T1 = T
1
0
[
0
0
0
1
0
0
0
0
1
0
2 0
0 1
][
0 0
1 0
−1
0
0
0
0
0
1
0
0
0 −1 0
0
1 0 0
]=[
0
0 0 1
1
0 0 0
2
0
]
0
1
Applying this to OABCDE
T × M = M’
0
1
[
0
0
−1
0
0
0
0
0
1
0
2 0
0 0
][
0 0
1 1
4
0
0
1
4
5
0
1
0
5
0
1
0
5
3
1
0
2
0
0
]= [
3
0
1
1
2 −3
4 4
0 0
1 1
−3
0
0
1
−3
0
3
1
2
0
]
3
1
To simplify M’ we divide each coordinate by the number in the fourth row, since all are equal
to 1 we can simply remove this row resulting in our transformation of the prism OABCDE:
2
𝑀 ′ = [0
0
z
5
2
4
0
−3
4
0
−3
0
0
−3
0
3
2
0]
3
3
-x
-3
-y
O
2
y
4
x
-z
Page | 11
Summary
Dilation matrix
Reflection matrix
X-axis
𝑠 0
[0 1
0 0
0
0]
1
Y-axis
1 0
[0 𝑠
0 0
XY-plane
1 0 0
[0 1 0 ]
0 0 −1
ZX-plane
−1 0
[0 1
0 0
Clockwise rotation
by 90°
Any rotation
1
[0
0
YZ-plane
1 0
[0 −1
0 0
0
0]
1
Z-axis
0 1 0
[−1 0 0]
0 0 1
0 −1 0
[1 0 0 ]
0 0 1
0
0
−1 0 ]
0 −1
0
0
cos 𝜃 − sin 𝜃 ]
sin 𝜃 cos 𝜃
−1 0 0
[0 1 0]
0 0 −1
cos 𝜃 0 sin 𝜃
[ 0
1
0 ]
− sin 𝜃 0 cos 𝜃
−1 0 0
[ 0 −1 0]
0
0 1
cos 𝜃 − sin 𝜃 0
[ sin 𝜃 cos 𝜃 0]
0
0
1
Translation Matrix
1 0 0 dx
0 1 0 𝑑𝑦
[
]
0 0 1 𝑑𝑧
0 0 0 1
Page | 12
0
0]
1
Y-axis
0 0 −1
[0 1 0 ]
1 0 0
0 0 1
[ 0 1 0]
−1 0 0
1
[0
0
Rotation by 180°
0
0]
𝑠
X-axis
0 0
0 1]
−1 0
0 0
0 −1]
1 0
1
[0
0
1
[0
0
Counterclockwise
rotation by 90°
0
0]
1
Z-axis
1 0
[0 1
0 0