Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Short Question:

If $T_\mathrm{loc}$, $P_\mathrm{rest}$ and $P_\mathrm{loc}$ are translation matrix and $T_\mathrm{rot}$ and $P_\mathrm{rot}$ are rotation matrix, how can I obtain values of $Q_\mathrm{loc}$ and $Q_\mathrm{rot}$ such that

$T_\mathrm{loc} \cdot T_\mathrm{rot} \cdot P_\mathrm{rest} \cdot P_\mathrm{loc} \cdot P_\mathrm{rot} = P_\mathrm{rest} \cdot Q_\mathrm{loc} \cdot Q_\mathrm{rot}$

where, $Q_\mathrm{loc}$ and $Q_\mathrm{rot}$ must be translation matrix and rotation matrix respectively.

Detailed Explanation:

I'm working on a (Computer Graphics) project where I want to multiply a transformation matrix $T$ (more precisely, $T = T_\mathrm{loc} \cdot T_\mathrm{rot}$, ie. it first rotates about world axis and then translates given point).

I already have $T$ and if I apply $T$ to a point $P_w$ I get appropriate $P_w'$.

However, my problem is I don't directly have $P_w$. I compute it as $P_w = P_\mathrm{rest} \cdot P_\mathrm{loc} \cdot P_\mathrm{rot}$. Also I want to get the result back in the same form $Q_\mathrm{loc}$ and $Q_\mathrm{rot}$ (ie. in 2 parts, a translation matrix and a rotation matrix).

I have tried

$Q_\mathrm{loc} = T_\mathrm{loc} \cdot P_\mathrm{loc}$ ...(since translations are commutative)
$Q_\mathrm{rot} = P_\mathrm{rest}^{-1} \cdot P_\mathrm{loc}^{-1} \cdot T_\mathrm{rot} \cdot P_\mathrm{rest} \cdot P_\mathrm{loc} \cdot P_\mathrm{rot}$

which mathematically should result in
$RHS = P_\mathrm{rest} \cdot Q_\mathrm{loc} \cdot Q_\mathrm{rot}$
$ = P_\mathrm{rest} \cdot T_\mathrm{loc} \cdot P_\mathrm{loc} \cdot P_\mathrm{rest}^{-1} \cdot P_\mathrm{loc}^{-1} \cdot T_\mathrm{rot} \cdot P_\mathrm{rest} \cdot P_\mathrm{loc} \cdot P_\mathrm{rot}$
$ = T_\mathrm{loc} \cdot T_\mathrm{rot} \cdot P_\mathrm{rest} \cdot P_\mathrm{loc} \cdot P_\mathrm{rot}$ ...(since translations are commutative)
$ = LHS$

However, I'm now convinced that the above will not work since $Q_\mathrm{rot}$ is a rotation matrix (ie. only rotation part) and hence there's no effect of $P_\mathrm{rest}^{-1}$ and $P_\mathrm{loc}^{-1}$.

I know this must be possible somehow since we can represent any point in 3D space with a rotation and a translation, but I'm lost. Any help would be greatly appreciated.

Thanks in advance.

share|cite|improve this question
and please someone create a tag "matrix-multiplication" or simply "multiplication" – mg007 Aug 22 '11 at 14:15
up vote 1 down vote accepted

Although I haven't completely understood your context (what all these matrices are for), the problem is easier when not thinking strictly in general matrix algebra, but using the special property of those matrices (they're all rigid-body transformations). First compute your left hand side, then left-divide by $P_{rest}$:

$P_{rest}^{-1} \cdot T_{loc} \cdot T_{rot} \cdot P_{rest} \cdot P_{loc} \cdot P_{rot} = Q_{loc} \cdot Q_{rot}$

The resulting matrix should be the product of $Q_{loc}$ and $Q_{rot}$. A product of rigid body matrices (which only contain translation and rotation, as in your case) is always a rigid-body matrix itself. So you can just decompose the resulting $Q_{loc} \cdot Q_{rot}$ into a rotation with successive translation, by just taking the rotation part ($Q_{rot}$) from the upper-left 3x3 part of the matrix (setting the last column and row to identity) and the translation part ($Q_{loc}$) from the last column (setting the upper-left 3x3 part to identity).

You will see, just copying the last column of $Q_{loc}$ into $Q_{rot}$ is equal to $Q_{loc} \cdot Q_{rot}$ if the former is a translation-only matrix and the latter a rotation-only matrix. But of course it wouldn't work that easy if the multiplication order was reversed.

share|cite|improve this answer
Thank you so much Christian! I already knew that last column of 4x4 matrix is a translation and upper-left 3x3 contains rotation information. However, I was not thinking in the right direction. But you've given a wonderful explanation! I'm pleased with your answer! Thanks again! – mg007 Aug 22 '11 at 18:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.