Rotate shape on a graph

140 Views Asked by At

I have some shape built out of points. The coordinates given for each point . (see pic below)enter image description here

I need to rotate this shape by a particular angle (for example 60° see pic below) enter image description here

Is there some formula to achieve this?

2

There are 2 best solutions below

1
On BEST ANSWER

Yes: take the collection of points $(x,y)$ and multiply them by the matrix

$$\left [ \begin {matrix} \cos{\theta} & -\sin{\theta} \\ \sin{\theta} & \cos{\theta} \end {matrix} \right ],$$

where $\theta = 60^\circ$, for example.

0
On

Indeed you can. If you multiply by a rotation matrix: $\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix} \cos\theta&-\sin\theta\\\sin \theta&\cos \theta\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}$, where $(x',y')$ are the coordinates after the rotation has been applied and $(x,y)$ are the coordinates before the rotation has been applied . After doing the matrix multiplication, you get $$x'=x\cos\theta-y\sin\theta$$ and $$y'=x\sin\theta+y\cos\theta$$