# Collision between a rotating circle and a line segment on a cartesian plane

I have the following collision detection problem that I am trying to solve:

I have a circle $$(x – h)^2 + (y – k)^2 = r^2$$ and a line segment $$\overline{AB}$$ on a cartesian plane. The circle is rotated around the origin $$O$$. $$\overline{AB}$$ lies in the path of the circle as it is rotated around $$O$$.

I am trying to determine the rotation, $$R$$ around $$O$$ at which the circle will 'collide' with $$\overline{AB}$$ (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 the circle $$\overline{AB}$$). However, I would like to know if there is a closed form solution to this problem.

• You are looking for the point $M$ on the larger circle such that the distance of $M$ to the line is $r$, so that the small circle is tangent to the line. If you know the distance from the line to $O$, and the radius of the larger circle, then you just need Pythagoras' theorem. Commented Feb 17, 2020 at 10:54
• Dear Jean-Claude - the point $M$ on the larger circle (the arc-path of the small circle's centroid) which lies tangential to the line segment by the distance $r$ is exactly what I am after (there are two solutions of course in this case). The radius of the large circle is known. Not sure what you mean by 'the distance from the line to $O$'. I assume this is from the point of collision ($P$) to $O$. If this is correct, then this is unknown. It would be great if you could elaborate on your comment! Commented Feb 17, 2020 at 13:12
• I mean the distance between $O$ and the orthogonal projection of $O$ on $AB$. If you know the equation of the line, it will also do (it's easy to find this distance then). Commented Feb 17, 2020 at 13:13
• Thanks again Jean-Claude. Apologies, but I still do not see the Pythagorean geometric solution given the knowns: i.e. the orthogonal projection of $O$ on $AB$ ($O'$), the distance between $O$ and $O'$ ($d$), the radius of the large circle $r_2$ and $r$. Thanks again! Commented Feb 17, 2020 at 13:52
• @DrThomas What is $\mathbf{\it{R}}$? Is that the distance the center of the small circle must travel from the point $\left(h, k\right)$ to bring about its collision with the line $AB$?
– YNK
Commented Feb 17, 2020 at 15:04

I also assume $$O$$ is at coordinates $$(0,0)$$, the larger circle $$\mathscr C$$ has radius $$R=\sqrt{h^2+k^2}$$, and the vertical line $$AB$$ cuts the horizontal axis at point $$H(a,0)$$.
We want the point $$M(x,y)$$ on $$\mathscr C$$ such that the circle of center $$M$$ and radius $$r$$ is tangent to $$AB$$. This means that $$x+r=a$$, and from $$x^2+y^2=R^2$$ we can find $$y$$.
• Ah, I see! so $a - r = x$, $x^2 + y^2 = R^2$, and $y = \sqrt{R^2 - x^2}$. Perfect... BTW my line segment is always is parallel or perpendicular to the horizontal axis. Commented Feb 17, 2020 at 19:05