Rotate a point on a circle with known radius and position

Having a circle $\circ A(x_a, y_a)$ of radius $R$ and a point on the circle $B(x_b, y_b)$, how can we rotate the point with a known angle $\alpha$ (radians or degrees, it doesn't really matter) on the circle so we will obtain a new point on the circle $C(x_c, y_c)$, like in the image below?

How to calculate the $C$ coordinates?

Here the rotation angle is $90 ^ {\circ}$. In this example, $x_b = x_a$, $y_b = R$, $\alpha = 90 ^ \circ$. From the image we see that $x_c = R$ and $y_c = y_a$.

However, I want a general solution for any $A, B, R$ and $\alpha$.


Let's look at a simpler problem. Suppose you have the situation depicted in the figure below:

enter image description here

Then, given the angle $\alpha$, the coordinates of the point $C''$ are:

$$ C''_x = r\cos\alpha \qquad\mbox{and}\qquad C''_y = r\sin\alpha $$

where $r$ is the radius of the circle.

Now let's look at a slightly more complicated problem, depicted below:

enter image description here

This is very similar to the situation above. In fact,

$$ C'_x = r\cos(\alpha+\beta) \qquad\mbox{and}\qquad C'_y = r\sin(\alpha+\beta) $$

By using the trigonometric relations $\sin(\alpha+\beta) = \sin\alpha\cos\beta + \sin\beta\cos\alpha$ and $\cos(\alpha+\beta) = \cos\alpha\cos\beta - \sin\alpha\sin\beta$, we can write the above as follows:

$$ C'_x = r\cos\alpha\cos\beta - r\sin\alpha\sin\beta \qquad\mbox{and}\qquad C'_y = r\sin\alpha\cos\beta + r\sin\beta\cos\alpha $$

But, wait... By looking at the previous situation and replacing $C''$ with $B'$ and $\alpha$ with $\beta$, we see that

$$ B'_x = r\cos\beta \qquad\mbox{and}\qquad B'_y = r\sin\beta $$

Therefore, we can write

$$ C'_x = B'_x\cos\alpha - B'_y\sin\alpha \qquad\mbox{and}\qquad C'_y = B'_x\sin\alpha + B'_y\cos\alpha $$

But what you want is this, instead:

enter image description here

Well, we can just move everything rigidly by the vector $-\vec{OA}$ so that $A$ is now the origin of the coordinate system and we get the situation just above. This amounts to subtracting $A$ from both $B$ and $C$ to get $B'$ and $C'$ in the above, and we find

$$ C_x - A_x = (B_x-A_x)\cos\alpha - (B_y-A_y)\sin\alpha $$ $$ C_y - A_y = (B_x-A_x)\sin\alpha + (B_y-A_y)\cos\alpha $$

Then, finally,

$$ C_x = A_x + (B_x-A_x)\cos\alpha - (B_y-A_y)\sin\alpha $$ $$ C_y = A_y + (B_x-A_x)\sin\alpha + (B_y-A_y)\cos\alpha $$


This is called an affine transformation. Basically, the idea is to temporarily shift our circle so that it's centered about the origin, apply a rotation matrix to the point as done in linear algebra, then shift it back. Using the notation you have in your problem, as well as adding $$M=\left(\begin{array}{cc} \cos(\alpha) & -\sin(\alpha)\\ \sin(\alpha) & \cos(\alpha)\\ \end{array}\right)$$ To represent the counterclockwise rotation through an angle $\alpha$ (if you want it clockwise like it appears in your picture, just swap the $-\sin(\alpha)$ with the $\sin(\alpha)$), this transformation is given by: $${C}=M(B-A)+A$$ where $A,B,C$ are the vectors representing their respective points.