decomposing rotation,translation,scale from matrix

Started by
4 comments, last by Sneftel 16 years, 6 months ago
Hi, I was wondering if anyone could point me in the right direction on the matter of how to decompose a transforation matrix to retrieve translation, rotation, and scale... Tried googling "matrix decomposition" and i got a few hits, but they didnt help me much; wikipedia has a bunch of different types of decomposition, but i know nothing about them and dont know if or which of them will help me. So anyway, i know that the translation can be easily retrieved by taking the last column of the matrix, but thats about it... Any hints on how i can get the scaling and rotation? they both use the same elements of a matrix...
Advertisement
The scaling/shearing and the rotation fall out of the QR decomposition of the 3x3 submatrix.
If the transforms have been combined in the order Scale->Rotate->Translate, you can:

1. Compute the length of the first three basis vectors of the matrix - these are your scale factors.

2. Divide the first three basis vectors through by the scale factors to yield a pure rotation.

3. Extract the translation from the fourth basis vector, as you mentioned.

There are other methods that can be used as well, but the above should suffice for your typical SRT affine transform.
You won't be able to extract the original transformations without knowing what order they were originally multiplied in. TRSx is the easiest order, since all three transformations remain relatively isolated in the final matrix. It's a little trickier for other orders, where things tend to get... jumbled :)
Im going to assume the matricies have been combined as scale->rotate->translate

So, it sounds like jyk's method will be the easiest; makes sense to me also

Though im curious about QR decomposition...I read through the wiki and I think I see how to extract Q and R, but how can I use these to get scale and rotation? Im guessing the diagonal of Q is my scale, and R is my rotation, but im just speculating...

(its amazing how wikipedia can also describe the equations and implementations of something but never how its usefull or how to use it :P)
Quote:Original post by coderchris
Though im curious about QR decomposition...I read through the wiki and I think I see how to extract Q and R, but how can I use these to get scale and rotation? Im guessing the diagonal of Q is my scale, and R is my rotation, but im just speculating...

Other way around. Otherwise, yes. And the reason that Wikipedia doesn't say that that's what it's for is that that is only one of the many, many things the QR decomposition can be used for.

This topic is closed to new replies.

Advertisement