How do you calculate the rotation matrix given a transformation?

239 Views Asked by At

This is something that I just cannot wrap my head around, no matter how much I read.

Given we have vectors on a plane (n = 2), how do I find the matrix $A$ that rotates any vector $v$ by $x^{\circ}$?

For instance, if I want to rotate a vector $v=(1,1)$ by 90 degrees counter-clockwise, the matrix $A$ is given by:

$$A = \Big(\begin{matrix} 0 & -1\\ 1 & 0 \end{matrix}\Big) $$

But how do I actually work this out? Ultimately, I can see that if I multiply A by my vector, it returns the vector that is rotated by 90degrees counter-clockwise, but I still don't know where A came from.

If the instruction was to find another matrix $B$ that did the rotation 50 degrees clockwise, what would be the thought process to solving such a question?

Thanks.

1

There are 1 best solutions below

1
On BEST ANSWER

Lets say you have a vector $v = (x,y)$. You can visualize $v$ as an arrow departing from the origin (0,0) in the cartesian plane.

The trick is to visualize $v$ inside a circle of radius $\|v\|$ centered at the origin. The vector $v$ would be the radius of the circle. We call $\theta$ the angle formed between $v$ and the $x$-axis.

You can check, by the definition of $\cos \theta$ function, that the $x$-coordinate of $v$ is equal to:

$x = \|v\| \cos \theta$

Similarly, you can check, by definition of $\sin \theta$ function, the $y$-coordinate of $v$ is equal to:

$y = \|v\| \sin \theta$

Now the rotation of vector $v$ by an angle $\alpha$ can be defined as:

$x' = \|v\| \cos (\theta + \alpha)$ $y' = \|v\| \sin (\theta + \alpha) $

That's it. However, it is in not in a matrix form. In order to put this in matrix form I will use the following trigonometric identities (from wikipedia):

$\cos (\theta + \alpha) = \cos \theta \cos \alpha - \sin \theta \sin \alpha$ $\sin (\theta + \alpha) = \sin \theta \cos \alpha + \cos \theta \sin \alpha$

So replacing we get:

$x' = \|v\| (\cos \theta \cos \alpha - \sin \theta \sin \alpha)$ $y' = \|v\| (\sin \theta \cos \alpha + \cos \theta \sin \alpha)$

Since $x = \|v\| \cos \theta$ and $y = \|v\| \sin \theta$ we get:

$x' = x \cos \alpha - y \sin \alpha$ $y' = y \cos \alpha + x \sin \alpha$

We are done. We can now arrange the above as a matrix product $v' = A v$ as you want.

If you replace $\alpha = 90°$ you can check you get the matrix you are familiar with.