# Find the coordinates of the centre of a circle which is tangent to a given circle

I am trying to program the situation as show in figure below.

I have two circles, with centres at $(x_1,y_1)$ and $(x_2,y_2)$. The line segment connecting $(x_1,y_1)$ and $(x_2,y_2)$ makes an angle $\theta_2$ with the horizontal. I need to find the point $(h,k)$, such that the circle with this centre is tangent to the circle with centre $(x_2,y_2)$, where the line segment connecting $(x_1,y_1)$ and $(h,k)$ makes an angle $\theta_1$ with the horizon. All the three circles are of the same radius $r$.

Knowns: $(x_1,y_1)$, $(x_2,y_2)$, $r$, $\theta_1$, $\theta_2$
Unknowns: $(h,k)$.

• Compute $\sqrt(h^2+k^2)$ by the triangle formed by the centers of the three circles. Two of the edges have known lengths and one of the angles is $\theta_1-\theta_2$. Then use the angle $\theta_2$ to find $\frac{k}{h}$. Commented Feb 7, 2016 at 23:13
• I am sorry but I have two remarks a) Show us that you have already worked on the problem. b) The way you present your problem is somewhat confusing : a circle is note AT $(x,y)$, its CENTER is ; it is not the circles that make an angle $\theta_k$, it is the angle between the two straight LINES that connect their centers, etc. Commented Feb 7, 2016 at 23:18
• I would like to seek your attention in extending the problem.In my current case, my angles are varying from 0 to 360 degrees. So, the only choice is to divide the problem into four cases to match four quadrants. Thanks for your attention. To JeanMarie, Your two remarks are infact correct. The angles are defined with respect to circles centers. Commented Feb 9, 2016 at 22:54

The circle with centre $(x_2,y_2)$ is described by $$(x-x_2)^2+(y-y_2)^2=r^2.$$ The circle with centre $(h,k)$ will be tangent to this circle, precisely if the point $(h,k)$ lies on $$(x-x_2)^2+(y-y_2)^2=(2r)^2.\tag{1}$$ Now, the point $(h,k)$ will lie on the line $$y=\tan(\theta_1)(x-x_1)+y_1.\tag{2}$$ Substite the expression $(2)$ into $(1)$ and you will find a quadratic equation in $x$. Solve this using your favorite method for solving quadratic equations and substitute your solutions back into $(2)$ to find the the coordinates $(h,k)$ for which the two circles are tangent.
As alway, you can find either two, one or no solutions for this equation. In the case where you find two solutions (call them $(h_1,k_1)$ and $(h_2,k_2)$), you must decide which one to pick. You should of course pick the solution that is closes to $(x_1,y_1)$.
N.B. Once you know $\theta_1$ and $\theta_2$, you can calculate directly wether or not the stones will hit, using the results of this answer. This might save you some time.