Removing rotation from a homogeneous 4x4 transformation matrix

I am working on a transformation matrix, and I want to do this in order to remove rotation transformation and preserve scaling, translation, etc.

How can I do it? I am trying to create a manually programmed solution.

+4
source share
3 answers

You need to use affine matrix decomposition, there are several methods with different pros and cons. You will need to study this. Here are some links to get you started:

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

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

It may be simpler or more complex depending on the nature of your transformation, although I assume it is affine. But if it is linear / rigid, then it is much simpler, if it is a promising transformation, then I assume that it will be more complicated.

+3
source

If you know for sure that your matrix rotates + translation + scaling, you can simply extract the necessary parameters:

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 this case part of the rotation is annoying, but if you just need translation and scaling ...

 translation = (m41, m42, m43) scale = sqrt(m11*m11 + m12*m12 + m13*m13) 
+2
source

The one-dimensional 4 Γ— 4 transformation matrix is ​​defined as follows:

 | x2 | | R11*SX R12*SY R13*SZ TX | | x1 | | y2 | = | R21*SX R22*SY R23*SZ TY | | y1 | | z2 | | R31*SX R32*SY R33*SZ TZ | | z1 | | 1 | | 0 0 0 1 | | 1 | 

where (SX,SY,SZ) are the scaling factors, (TX,TY,TZ) are the translation coefficients, and Rij are the rotation coefficients.

Getting the translation is trivial since you select the last column. To get the scaling, you use the property that the transformation is the rotation time of the diagonal scaling ( A=R*S ) and, therefore,

 tr(A)*A = tr(R*S)*(R*S) = tr(S)*tr(R)*R*S = tr(S)*S 

where tr(A) is the transpose operator. To calculate scaling factors

 S2 = tr(A)*A 

and select the square root of the first three diagonal terms

 SX = sqrt(S2(1,1)) SY = sqrt(S2(2,2)) SZ = sqrt(S2(3,3)) 

Then create a new transformation as:

 | SX 0 0 TX | | 0 SY 0 TY | | 0 0 SZ TZ | | 0 0 0 1 | 
+1
source

Source: https://habr.com/ru/post/1411922/


All Articles