# comp.graphics.algorithms

## Subject: Re: 4x4 matrix inversion

> > Deriving the n = 4 version is left as an exercise:)
>
> The OP indicated that his matrices are built from affine
> transformations but stored in 4-by-4 matrices. It is
> probably better not to invert it by a general 4-by-4
> process.

True. This is due to the zeros and the one in an affine matrix. For the
OP:

Let an affine 4x4 matrix A be represented by

A = [M P]
[0 1]

where
M is a 3x3 matrix
P is a 3x1 matrix
0 is a 1x3 matrix, with all entries zero
1 is a 1x1 matrix, with the only entry one

Similarly, let an affine 4x4 matrix B be represented by:

B = [N Q]
[0 1]

where
N, Q, 0, 1 are defined similarly to matrix A

Then
A * B = [M * N, M * Q + P]
[0 , 1 ]

From this we see that a multiplication of two affine transform matrices
yields an affine transform matrix.

Lets equate this to the identity matrix:

A * B = [M * N, M * Q + P] = [I, 0]
[0 , 1 ] [0, 1]

We obtain the system of equations:

{ M * N = I
{ M * Q + P = 0

Assuming M is non-singular:

N = M^-1
Q = -(M^-1)P

Thus

If

A = [M, P]
[0, 1]

and M is non-singular

then

A^-1 = [M^-1, -(M^-1)P]
[0, 1 ]

(This is the same result as Dave suggested)

Thus inverting an affine transformation does not require a full-blown
4x4 inversion.

Furthermore, if M is orthogonal such that
M^-1 = M^T

Then

A^-1 = [M^T, -(M^T)P]
[0, 1 ]

--
Kalle Rutanen
http://kaba.hilvi.org