Formula for rotating a vector in 2D¶
Let’s say we have a point (x1,y1). The point also defines the vector (x1,y1).
We rotate this vector anticlockwise around the origin by β degrees.
The rotated vector has coordinates (x2,y2).
Can we get the coordintes of (x2,y2) given (x1,y1) and β?

L is the length of the vectors (x1,y1) and (x2,y2) : L=‖.
\alpha is the angle between the x axis and (x_1, y_1).
We can see from the picture that:
We are going to use some basic trigonometry to get the lengths of r, u, t, s.
Because the angles in a triangle sum to 180 degrees, \phi on the picture is 90 - \alpha and therefore the angle between lines q, t is also \alpha.
Remembering the definitions of \cos and \sin:
Thus:
So:
Luckily this is the same result as wikipedia on rotation matrices.