In homogeneous coordinates, a rotation matrix around the origin can be described as

$R = \begin{bmatrix}\cos(\theta) & -\sin(\theta) & 0\\\sin(\theta) & \cos(\theta) & 0 \\ 0&0&1\end{bmatrix}$

with the angle $\theta$ and the rotation being counter-clockwise.

A translation amongst $x$ and $y$ can be defined as:

$T(x,y) = \begin{bmatrix}1&0&x\\ 0& 1&y\\0&0&1\end{bmatrix}$

As I understand, the rotation matrix around an arbitrary point, can be expressed as moving the rotation point to the origin, rotating around the origin and moving back to the original position. The formula of this operations can be described in a simple multiplication of

$T(x,y) * R * T(-x,-y) \qquad (I)$

I find this to be counter-intuitive. In my understanding, it should be

$T(-x,-y) * R * T(x,y) \qquad (II)$

The two formulations are definitely not equal. The first equation yields

$E1 = \begin{bmatrix}\cos(\theta) & -\sin(\theta) & -x\cdot\cos(\theta)+y\cdot\sin(\theta)+x\\\sin(\theta) & \cos(\theta) & -x\cdot\sin(\theta)-y\cdot\cos(\theta)+y \\ 0&0&1\end{bmatrix}$

The second one:

$E2 = \begin{bmatrix}\cos(\theta) & -\sin(\theta) & x\cdot\cos(\theta)-y\cdot\sin(\theta)-x\\\sin(\theta) & \cos(\theta) & x\cdot\sin(\theta)+y\cdot\cos(\theta)-y \\ 0&0&1\end{bmatrix}$

So, which one is correct?


Your first formula is correct. Remember, the point to which this is applied appears on the RIGHT: $$ T(x,y) * R * T(-x,-y) (P) $$ So to evaluate the expression above, we first translate $P$ by $(-x, -y)$, then rotate the result, then translate back. Let's see what happens when $P$ is the point $(x, y, 1)$. That amounts to evaluating the following product: \begin{align} f((x, y)) &= \begin{bmatrix}1&0&x\\ 0& 1&y\\0&0&1\end{bmatrix} \begin{bmatrix}\cos(\theta) & -\sin(\theta) & 0\\\sin(\theta) & \cos(\theta) & 0 \\ 0&0&1\end{bmatrix} \begin{bmatrix}1&0&-x\\ 0& 1&-y\\0&0&1\end{bmatrix} \begin{bmatrix}x\\ y\\1\end{bmatrix}\\ &= \begin{bmatrix}1&0&x\\ 0& 1&y\\0&0&1\end{bmatrix} \begin{bmatrix}\cos(\theta) & -\sin(\theta) & 0\\\sin(\theta) & \cos(\theta) & 0 \\ 0&0&1\end{bmatrix} \begin{bmatrix}0\\ 0\\1\end{bmatrix}\\ &= \begin{bmatrix}1&0&x\\ 0& 1&y\\0&0&1\end{bmatrix} \begin{bmatrix}0\\ 0\\1\end{bmatrix}\\ &= \begin{bmatrix}x\\ y\\1\end{bmatrix}\\ \end{align} as expected: the point $(x, y)$ remains fixed by this composite transformation.

  • $\begingroup$ what would happen if you first translated by the negative Matrix (in other words flipped the translate order)? $\endgroup$
    – Startec
    Jan 17 '19 at 9:00
  • 1
    $\begingroup$ If you flipped the translate order, you'd find yourself rotation by the angle $\theta$ around the point $(-x, -y)$ instead of $(x, y)$. $\endgroup$ Jan 17 '19 at 11:40
  • $\begingroup$ @John Hughes, Thanks for the answer, Prof. Hughes. I would like to have some follow up questions. It seems you multiply the 4 matrixes from RIGHT to LEFT. Is it the right way to do it ? Some textbook says that we should multiply the matrix from LEFT to RIGHT. Matrix multiplication is not associative, right ? $\endgroup$ Apr 29 at 23:25
  • $\begingroup$ Matrix multiplication is associative; it's not commutative in general. If your text works with positions represented as row vectors, then you need to reverse everything I've written (i.e., write something like $P * T(-x, -y) * R * T(x, y)$, where each of the $T$ and $R$ matrices must be transposed as well. $\endgroup$ Apr 29 at 23:43

The point is, that you're shifting the coordinate system, not the point.
So you don't actually shift the point to the origin, you shift the origin to the point, and then back.

  • $\begingroup$ Regardless of whether you think of the math as "shifting the coordinate system" or "shifting the point", the first operation you apply, as John Hughes correctly explains, is T(-x, -y). If that transform is applied to the point, the result is (0, 0). IMHO its simpler to get this math correct, if you think of this operation as "shifting the point to the origin". Hmm, or maybe you are working with post-multiplications rather than pre-multiplications. So its a question of POV. $\endgroup$ Mar 22 '18 at 14:09

These matrices are left-side multiplicated with vector positions, so the order of multiplication is from right to left - on the right side is the first operation, on the left side - the last one.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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