**comp.graphics.algorithms**

## Subject: **Re: 4x4 matrix inversion**

On Thu, 11 May 2006 15:03:04 GMT, "David Arden Stevensonn"

>I would be applying scale/rotation/translation to that matrix. I guess I

>wanted to show how it was set up initially. Specifically I need to invert it

>to use for a 3D camera. Additional code from my existing class below.

Remember that normals will transform with a different matrix than

points, and be sure the camera matrix does not include a perspective

transformation if you want a cheap inverse.

When possible we prefer to avoid a massive 4x4 inverse calculation,

but for efficiency and for numerical accuracy. Various facts have been

used over the years to help.

For a numerical analyst, inversion of large matrices is typically

replaced by a matrix factorization, such as LU or QR decomposition.

Mathematics books will talk about using "minors", and if we have an

affine matrix (where the last row entries are zero or one) this will

automatically produce a cheaper calculation if we apply the obvious

optimizations. Rotations and reflections leaving the origin fixed are

trivial to invert; for a rotation the inverse is the transpose, and

for a reflection the inverse is the original matrix. The inverse of a

translation merely negates the translation vector. And the inverse of

a product AB is the product of the inverses in the opposite order,

B^{-1}A^{-1}.

Sometimes we are confronted with a singular matrix having no inverse,

but in homogeneous coordinates we can use the adjugate matrix, which

is the same as the inverse except that it omits the division by the

determinant (which would be zero for a singular matrix). It's a great

trick, but use it with care because it can have unwanted side effects.

Reply

View All Messages in

**comp.graphics.algorithms**

path:

4x4 matrix inversion =>Re: 4x4 matrix inversion =>Re: 4x4 matrix inversion =>

Replies:

Copyright © 2006 WatermarkFactory.com. All Rights Reserved.