# Points of intersection of a line with two circles

I have the following representation: - line pass through the centers of the circles

I have to find the coordinates of the points of intersection of the line with circles (4 points). From these 4 points I have to choose 2 points , so that the distance between them to be minimal .

If I denote the coordinates of the center of the circle with $x_a,y_a$ (respectively ,$x_b,y_b$) and radius with $r_a$ , $(r_b)$ I have the following:

$(x+x_a)^2+(y+y_a)^2=r_a^2$ (circle A)

$(x+x_b)^2+(y+y_b)^2=r_b^2$(circle B)

$(x-x_a)/(x_b-x_a)=(y-y_a)/(y_b-y_a)$(line)

Computing the system with WolframAlpha I got some bulky answers.

Is there any trick to ease the solving of the system ? Thanks in advance.

• I'm not sure I understand your question; there seem to be only 2 points of intersection between the circles and the line. – recursive recursion Mar 10 '14 at 19:25

You can approach this I think quite simply using just vectors. You are given $x_a$, $y_a$, and $r_a$, as well as $x_b$, $y_b$ and $r_b$. Let $a = \begin{bmatrix} x_a \\ y_a \end{bmatrix}$, and similarly $b = \begin{bmatrix} x_b \\ y_b \end{bmatrix}$. The unit vector from $A$ toward $B$ is given by $$v_{ab} = \frac{b-a}{|b-a|}$$ Then your four points are simply $$a \pm r_a v_{ab}$$ and $$b \pm r_b v_{ab}$$