Game Development Reference

In-Depth Information

1.4 Matrices and Transformations

1.4.1 Definition

A
matrix
is an
m

n
array of components with
m
rows and
n
columns. These

components could be complex numbers, vectors, or even other matrices, but most

of the time when we refer to a matrix, its components are real numbers. An

example of a 2
×
3 matrix is

×

5

.

−
1

0

12

0

−
10

We refer to a single element in the
i
th row and
j
th column of the matrix
A
as
a
ij
.

Those elements where
i
=
j
are the
diagonal
of the matrix.

A matrix whose elements below and to the left of the diagonal (i.e., those

where
i>j
) are 0 is called an
upper triangular
matrix. Similarly, a matrix

whose elements above and to the right of the diagonal (i.e., those where
i<j
)

are 0 is called a
lower triangular
matrix. And those where all the non-diagonal

elements are 0 are called
diagonal
matrices.

A matrix is called
symmetric
if, for all
i
and
j
, the elements
a
ij
=
a
ji
, i.e., it

is mirrored across the diagonal. A matrix is
skew symmetric
if for all
i
and
j
the

elements
a
ij
=

−

a
ji
. Clearly, the diagonal elements must be 0 in this case.

1.4.2 Basic Operations

Matrices can be added and scaled like vectors:

C
=
A
+
B
,

D
=

k
A
.

In the first case, each element
c
ij
=
a
ij
+
b
ij
, and in the second,
d
ij
=
ka
ij
.

Matrices can be transposed by swapping elements across the diagonal, i.e.,

amatrix
G
is the transpose of matrix
A
if for all
i
and
j
,
g
ij
=
a
ji
.Thisis

represented as

G
=
A
T
.

Finally, matrices can be multiplied:

H
=
AB
.

Here, for a given element
h
ij
, we take the corresponding row
i
from
A
and cor-

responding column
j
from
B
, multiply them component-wise, and take the sum,

or

h
ij
=

k

a
ik
b
kj
.