$$\begin{cases}x' = x \cos(\varphi) - y \sin(\varphi) \\ y' = x \sin(\varphi) + y \cos(\varphi)\end{cases}$$
This a the formula for rotating $(x, y)$ by $\varphi$. It works well when I want to rotate rectangle's vertices which is centered in $(0, 0)$ but what if center is not zero and It's something like $(5, 10)$ ?
Then the formula will just change to accomodate the new origin.
$$x' = 5+(x-5) \cos(\varphi) - (y-10) \sin(\varphi) \\ y' = 10+(x-5) \sin(\varphi) + (y-10) \cos(\varphi)$$
I hope this helps you.