Rotation between two circles

390 Views Asked by At

I have the following collision detection problem that I am trying to solve. I am more of a programmer than a mathematician so please go easy on me!

I have two circles on a Cartesian plane defined by their centroids $(p_1, p_2)$ and their radii $(r_1, r_2)$. Circle 1 is rotated around the origin $O$. Circle 2 lies in the path of circle 1 as it is rotated around $O$. $p_1$ and $p_2$ do not intersect under this rotation (otherwise the solution I seek would be trivial).

I am trying to determine the rotation, $R$ around $O$ at which circle 1 will 'collide' with circle 2 (see the linked image). I can solve this iteratively (i.e. incrementally rotate circle 1 around the origin of the reference frame and test for intersection between circle 1 and circle 2). However, I would like to know if there is a closed form solution to this problem.

Linked image: https://www.dropbox.com/s/2nevu15hib1onf4/circ_rot.png?dl=0

Thanks in advance!

2

There are 2 best solutions below

1
On BEST ANSWER

Use the law of cosines. If $\rho_i$ denotes the distance of $p_i$ from the origin, and you want the distance between the centres to be $r_1+r_2$, you need the angle bewteen the lines from the origin to the centres to form an angle $\theta$ that satisfies

$$ (r_1+r_2)^2=\rho_1^2+\rho_2^2-2\rho_1\rho_2\cos\theta\;, $$

and thus

$$ \theta=\arccos\frac{\rho_1^2+\rho_2^2-(r_1+r_2)^2}{2\rho_1\rho_2}\;. $$

Then you just need to calculate the angle originally formed by these lines and rotate by the difference of the two angles.

0
On

HINT:

First circle has equation

$$ (x-h1)^2 + (y-k1)^2 = r_1^2 \tag1 $$

If you rotate its center through angle $\beta$

$$(x-[h1 \cos \beta-k1 \sin \beta])^2+(y-[h1 \sin \beta + k1\cos \beta ])^2 = r_1^2 \tag2 $$

This circle and the second circle below

$$ (x-h2)^2 + (y-k2)^2 = r_2^2 \tag3 $$

should touch. This is ensured when coordinates x or y are solved for the discriminant of quadratic so formed vanishes for a coincident root situation.

Unknown $\beta $ can be solved for. May be a bit cumbersome.