I'm in the process of learning game development and have a question regarding a simple rotation. So far, I'm visualizing the rotation as such:
I've read this similar question but I'm struggling to understand how to apply this given formula:
$$ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} \cos{\theta} & -\sin{\theta} \\ \sin{\theta} & \cos{\theta} \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} $$
Given a point of $(2,3)$, what would the point be after a rotation in the $xy$ plane about the origin through an angle of $-180$ degrees?
$$ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} \cos{-180} & -\sin{-180} \\ \sin{-180} & \cos{-180} \end{bmatrix} \begin{bmatrix} 2 \\ 3 \end{bmatrix} $$
Is this correct?
$\endgroup$1 Answer
$\begingroup$The difficulty you seem to be having is with matrix multiplication. I suggest that you watch the Khan Academy videos on this, as he does a great job of explaining it.
For your example, we apply this as follows: $$\left[\begin{matrix} x' \\ y' \end{matrix}\right] = \left[\begin{matrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{matrix}\right] \left[\begin{matrix} x \\ y \end{matrix}\right] $$
$$\left[\begin{matrix} x' \\ y' \end{matrix}\right] = \left[\begin{matrix} \cos180& -\sin180\\ \sin180& \cos180 \end{matrix}\right] \left[\begin{matrix} 2 \\ 3 \end{matrix}\right] $$
$$\left[\begin{matrix} x' \\ y' \end{matrix}\right] = \left[\begin{matrix} -1 & 0\\ 0& -1 \end{matrix}\right] \left[\begin{matrix} 2 \\ 3 \end{matrix}\right] $$
$$\left[\begin{matrix} x' \\ y' \end{matrix}\right] = \left[\begin{matrix} (-1)(2)+ (0)(3)\\ (0)(2) + (-1)(3) \end{matrix}\right] $$
$$\left[\begin{matrix} x' \\ y' \end{matrix}\right] = \left[\begin{matrix} -2 \\ -3 \end{matrix}\right] $$
So, a rotation of $180$ degrees results in a new point of $(-2, -3)$.
$\endgroup$ 3