Original Post
Hi, I want to know how to decompose a matrix44 to scale, rotation and translation? Though I know how to compose these to a matrix. But it seems much more difficult to decompose a matrix.
Quote:If you're using the DirectX library, I think there's a function available for this. Otherwise, if the order of transformation was scale->rotate->translate, it's fairly easy to do manually. The scale factors are the lengths of the basis vectors of the matrix. Once you have the lengths, you can normalize the vectors to get an orthonormal basis (the rotation matrix). The translation is unaffected by the concatenation and can simply be extracted directly from the matrix.
Original post by zhouzhengchun
I want to know how to decompose a matrix44 to scale, rotation and translation? Though I know how to compose these to a matrix. But it seems much more difficult to decompose a matrix.
Quote:
Original post by jyk
Otherwise, if the order of transformation was scale->rotate->translate, it's fairly easy to do manually. The scale factors are the lengths of the basis vectors of the matrix. Once you have the lengths, you can normalize the vectors to get an orthonormal basis (the rotation matrix).
Quote:Yes, my suggestion was just for the simple case of a single scale->rotate->translate sequence - I didn't mean to imply that it was a general solution (I think my post was fairly clear in that regard). In any case, the OP now has some options to choose from :)
Original post by Wasting Time Quote:
Original post by jyk
Otherwise, if the order of transformation was scale->rotate->translate, it's fairly easy to do manually. The scale factors are the lengths of the basis vectors of the matrix. Once you have the lengths, you can normalize the vectors to get an orthonormal basis (the rotation matrix).
If you know you have Y=S*R*X+T, where S is a diagonal matrix of scales, R is a rotation, and T is a translation, then you can figure out S, R, and T as you indicated. The problem is when you have a composition of such transformations. The translation is not a problem to figure out when you have Y=M*X+T. The decomposition of M = S*R, where S is a diagonal matrix and R is an orthogonal matrix, is not always possible. The best you can do is "polar decomposition", where S is a symmetric matrix that represents the scaling, but in a different coordinate system, or "singular value decomposition" M = L*D*R, where L and R are orthogonal and D is a diagonal matrix of nonnegative values (the diagonal terms are positive when M is invertible). The function decomp_affine() mentioned in another follow-up post essentially does this type of decomposition.
[ m11 m12 m13 m14 ][ m21 m22 m23 m24 ][ m31 m32 m32 m34 ][ 0 0 0 1 ]Quote:
Original post by someusername
Why should the order of individual -hardcoded- transformations, matter at all? (in finding the S/R/T components, that is)
And besides, I don't see the need for any sort of matrix decomposition here...
Quote:This is exactly what I described previously. However, it only works for a single (albeit common) case, whereas the decompositions suggested by the other posters are more general.
Original post by someusername
It is obvious now, that the scaling values are |sgX|, |sgY|, |sgZ|, the new orientation base is:
{sgX/|sgX|, sgY/|sgY|, sgZ/|sgZ|}, and the translation is {m14, m24, m34}.
The respective S/R/T matrices, can be constructed trivially from the above vectors and values, if they are *that* necessary...
Quote:
Original post by jyk
The OP did specify scale, rotation, and translation. He didn't specify the order, but I think S->R->T is a pretty good bet, which is why the aforementioned shortcut seems like a reasonable suggestion.
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more