# How far to move a circle along a ray so that it intersects with another circle only once?

Given two 2d circles that have intersected at two points, how do I find the distance along a ray that passes through the center of one of the circles so that when that circle is translated along that ray for that distance, the circles intersect exactly once?

In the above image, I'm trying to find the distance between the green points. The information I have is: both centers and radii, and the ray direction vector.

Thanks!

Update: Here is a diagram with the known/unknown lengths and angles:

In the triangle, the green line lengths are known and the green angle is known. The red ones are unknown. I thought about using the law of sines/cosines to solve for the angles, but it doesn't seem to me that I have enough information.

• Nice diagram! What have you tried so far? Try to include this in your post description. – Eoin Nov 7 '14 at 6:25
• Well, I tried (the sum of their radii) - (distance between centers), but this is usually wrong. – xytor Nov 7 '14 at 6:31

Hint: When the circles are tangent, the distance between their centers is the sum of the two radii. The Pythagorean Theorem should get you the rest of the way there.

• The problem is that there are no right angles... – xytor Nov 7 '14 at 6:35
• But at least this will get you another length! Do you have the distance from the center of the black circle to the orignial position of the green dot? This would get you 2 lengths and then much could be obtained. – Eoin Nov 7 '14 at 6:37
• This seems to be the "Ambiguous case" from trig, when the only known angle is opposite to a known length. – xytor Nov 7 '14 at 7:04
• Solved! Answer posted. Thanks! – xytor Nov 7 '14 at 8:31

Given the second diagram, let the angles be A, B and C and the lengths be a, b and c. Lengths a and b are known, and only the angle B is known. We want to find c. To do that, we first need to find A using the law of sines:

$A = \sin^{-1}(\sin(B) * \frac{a}{b})$

Now we can find c using the law of cosines. Since this is ambiguous, there will be two answers:

$c = b*\cos(A) \pm \sqrt{a^2+b^2*\cos^2(A)-b^2}$

To find which c is correct, I simply moved the circle and tested which b was closest to the sum of radii.