Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove rotation from a 4x4 homogeneous transformation matrix

Tags:

math

matrix

I am working on a transformation matrix, and what I want done is to remove the rotation transformation and preserve the scaling, translation, etc.

How do I do this? I am seeking to create a manually-programmed solution.

like image 683
brain56 Avatar asked May 11 '12 06:05

brain56


2 Answers

You need to use an affine matrix decomposition, there are a few methods with different pros and cons. You'll have to look into it. Here are a few links to get you started though:

http://callumhay.blogspot.com/2010/10/decomposing-affine-transforms.html

http://www.itk.org/pipermail/insight-users/2006-August/019025.html

This could be simpler or more complicated depending on the nature of your transformation though, I'm assuming it's affine. But if it's linear / rigid then this is much easier, if it's a perspective transformation then I imagine it will be more complex.

like image 57
Dan Avatar answered Sep 23 '22 06:09

Dan


If you know for sure that your matrix is rotation+translation+scaling then you can just extract the parameters you need:

rotation = atan2(m12, m11)
scale = sqrt(m11*m11 + m12*m12)
translation = (m31, m32)

edit

I didn't notice that you are interested in 3d transformations, in that case the rotation part is the annoying one, but if you just want translation and scale...

translation = (m41, m42, m43)
scale = sqrt(m11*m11 + m12*m12 + m13*m13)
like image 31
6502 Avatar answered Sep 24 '22 06:09

6502