# Very handy matrix functions - part 1

• 05-09-2004
VirtualAce
Very handy matrix functions - part 1
I finished reading my 3D math book and let me tell you it was full of information that I've been searching for...for a very long time.

Granted the D3DX library of functions can do most anything with matrices but it is nice to know the math behind it.

For instance...here is how to find the determinant of a 2D matrix.

[m11 m12]
[m21 m22]

d=((m11m22)-(m12m21))

So for a 3x3 would be:

[m11 m12 m13]
[m21 m22 m23]
[m31 m32 m33]

((m11m22m33)+(m12m23m31)+(m13m21m32))-
((m13m22m31)+(m12m21m33)+(m11m23m32))

But this changes for a nxn matrix.

Essentially you must divide the matrix up into submatrixes called cofactors. Take the sum of all the determinants of the cofactors and you have the determinant of the matrix.

Here is an example of a cofactor:

[m11 m12 m13]
[m21 m22 m23]
[m31 m32 m33]

C11=
[m22 m23]
[m32 m33]

:C11:=(m22m33)-(m23m32)

So:
:C11:+
:C12:+
:C13:+
:C21:+
:C22:+
:C23:+
:C31:+
:C32:+
:C33:=
:M:
• 05-09-2004