4
$\begingroup$

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$.

$\endgroup$
  • $\begingroup$ Are you familiar with rotation matrix ? Change of origin ? $\endgroup$ – Shailesh Aug 5 '15 at 7:02
  • $\begingroup$ @Shailesh I saw something on Wikipedia, but didn't really understood the things. I think I know what the origin change means. $\endgroup$ – Ionică Bizău Aug 5 '15 at 7:04
  • $\begingroup$ Anyways Brent has given a complete answer. I was trying to lead you towards it. $\endgroup$ – Shailesh Aug 5 '15 at 7:41
8
$\begingroup$

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 $$

$\endgroup$
  • $\begingroup$ This is also helpful, but I don't understand there the radius $r$ disappeared in the final solution. Isn't it supposed to be there as well? $\endgroup$ – Ionică Bizău Aug 5 '15 at 7:47
  • $\begingroup$ It is! It's hidden in the coordinates of $A$ and $B$. For example, $B_x - A_x = r\cos\beta$. $\endgroup$ – wltrup Aug 5 '15 at 7:49
  • $\begingroup$ Nice! Upvoted you! $\endgroup$ – Ionică Bizău Aug 5 '15 at 7:55
  • $\begingroup$ Thanks. Too bad it took me too long to do the pictures. I was hoping to have my answer accepted but Brent beat me to it. lol $\endgroup$ – wltrup Aug 5 '15 at 7:57
  • $\begingroup$ Oh, one last thing: my angle $\alpha$ is the negative of yours since I have the locations of $B$ and $C$ exchanged with respect to your picture. $\endgroup$ – wltrup Aug 5 '15 at 8:15
3
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ where A,B,C are the vectors representing their respective points. -- how to build these vectors? Also, how to multiply $M(B - A)$? $\endgroup$ – Ionică Bizău Aug 5 '15 at 7:19
  • 1
    $\begingroup$ For example, in your picture, you have $A$ as the point $(x_a,y_a)$, so it would be the vector $\left(\begin{array}{c}x_a \\ y_a \end{array}\right)$. Multiplying $M(B-A)$ is done using matrix multiplication: en.wikipedia.org/wiki/… $\endgroup$ – Brent Aug 5 '15 at 7:34
  • $\begingroup$ Ah, sounds good! Actually, it's multiplying two matrix. Thanks a lot! $\endgroup$ – Ionică Bizău Aug 5 '15 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.