[Math] rotate vector around a point using matrices

linear algebramatrices

Im trying to rotate a vector around a point.
For this example lets say i want to rotate 30 degrees around point 2,3
I learned that it takes 3 steps

1. move vector using a "move matrix".

so the matrix would look like:

(matrix 1)

$$
\begin{bmatrix}1&0&2\\ 0&1&3\\ 0&0&1\end{bmatrix}.
$$

2. rotate using a rotation matrix

$$
\begin{bmatrix}
\cos 30& -\sin 30& 0\\
\sin 30& \cos 30& 0\\
0& 0& 1
\end{bmatrix}=\begin{bmatrix}
.866& -.5& 0\\
.5& .866& 0\\
0& 0& 1
\end{bmatrix}
$$
3. move back using a "move matrix" (same as matrix one using negative values for x and y):

(matrix 3)

$$
\begin{bmatrix}1&0&-2\\ 0&1&-3\\ 0&0&1\end{bmatrix}.
$$

But I don't understand how I should do these steps.
Should I multipy matrix one with matrix two, the result of this with matrix 3 and the result of that with my input, or the input with the result?

Or should I take my input, multiply with matrix 1, multiply the result with matrix 2 and after that multiply that result with matrix 3? I understand the steps but im not sure how to use these steps (if that makes sense).

edit:

lets call my input i

$$
\begin{bmatrix}x\\ y\\ 1\end{bmatrix}.
$$

should I do

$$
m1 * m2 * m3* i
$$

or

$$
i * m1 * m2 * m3
$$
or
$$
(i * m1) * (i * m2) * (i * m3)
$$

If anyone is able to find a link to a solved transformation that would be incredible helpfull, that way I can check if im doing it correctly.

Best Answer

$\begin{bmatrix}1&0&2\\ 0&1&3\\ 0&0&1\end{bmatrix} \begin{bmatrix} \cos 30& -\sin 30& 0\\ \sin 30& \cos 30& 0\\ 0& 0& 1 \end{bmatrix} \begin{bmatrix}1&0&-2\\ 0&1&-3\\ 0&0&1\end{bmatrix} \begin{bmatrix}x\\ y\\ 1\end{bmatrix}$

$\begin{bmatrix}1&0&2\\ 0&1&3\\ 0&0&1\end{bmatrix} \begin{bmatrix} \cos 30& -\sin 30& 0\\ \sin 30& \cos 30& 0\\ 0& 0& 1 \end{bmatrix} \begin{bmatrix}x-2\\ y-3\\ 1\end{bmatrix}$

$\begin{bmatrix}1&0&2\\ 0&1&3\\ 0&0&1\end{bmatrix} \begin{bmatrix}(x-2)\cos 30 - (y-3)\sin 30\\ (x-2)\sin 30+ (y-3)\cos30\\ 1\end{bmatrix}$

$\begin{bmatrix}(x-2)\cos 30 - (y-3)\sin 30+2\\ (x-2)\sin 30+ (y-3)\cos30+3\\ 1\end{bmatrix}$

Alternatively,

$\begin{bmatrix}1&0&2\\ 0&1&3\\ 0&0&1\end{bmatrix} \begin{bmatrix} \cos 30& -\sin 30& 0\\ \sin 30& \cos 30& 0\\ 0& 0& 1 \end{bmatrix} \begin{bmatrix}1&0&-2\\ 0&1&-3\\ 0&0&1\end{bmatrix} \begin{bmatrix}x\\ y\\ 1\end{bmatrix}$

$\begin{bmatrix} \cos 30& -\sin 30& 2\\ \sin 30& \cos 30& 3\\ 0& 0& 1 \end{bmatrix} \begin{bmatrix}1&0&-2\\ 0&1&-3\\ 0&0&1\end{bmatrix} \begin{bmatrix}x\\ y\\ 1\end{bmatrix}$

$\begin{bmatrix} \cos 30& -\sin 30& -2\cos 30 + 3\sin30+2\\ \sin 30& \cos 30& -2\sin 30 - 3\cos 30 +3\\ 0& 0& 1 \end{bmatrix} \begin{bmatrix}x\\ y\\ 1\end{bmatrix}$

$\begin{bmatrix} x\cos 30 -y\sin 30 -2\cos 30 + 3\sin30+2\\ x\sin 30 +y\cos 30 -2\sin 30 - 3\cos 30 +3\\ 1 \end{bmatrix}=\begin{bmatrix}(x-2)\cos 30 - (y-3)\sin 30+2\\ (x-2)\sin 30+ (y-3)\cos30+3\\ 1\end{bmatrix} $