Game Development Reference

In-Depth Information

We find the determinant of a 3×3 matrix by first expanding the matrix by minors, and

then resolving the determinants of the 2×2 minors. Here's how you expand a 3×3 matrix

by minors:

Here's how this all looks in code:

inline float Matrix3x3::det(void)

{

return e11*e22*e33 -

e11*e32*e23 +

e21*e32*e13 -

e21*e12*e33 +

e31*e12*e23 -

e31*e22*e13;

}

Transpose

The method
Transpose
transposes the matrix by swapping rows with columns—that

is, the elements in the first row become the elements in the first column and so on for

the second and third rows and columns. The following relations are true for transpose

operations:

(
M
t
)
t
=
M

(s
M
)
t
= s (
M
t
)

(
M N
)
t
=
N
t
M
t

(
M
+
N
)
t
=
M
t
+
N
t

det[
M
t
] = det[
M
]

Here
M
and
N
are matrices,
t
is the transpose operator, and
s
is a scalar.

Here's the
Transpose
method for our
Matrix3x3
class:

inline Matrix3x3 Matrix3x3::Transpose(void)

{

return Matrix3x3(e11,e21,e31,e12,e22,e32,e13,e23,e33);

}

Inverse

The method
Inverse
computes the inverse matrix such that the following relation is

satisfied:

M M
−1
=
M
−1
M
=
I