Sign in to follow this  
coderchris

decomposing rotation,translation,scale from matrix

Recommended Posts

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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this