# Find circle going through point of horizontal line $g_1$ and tangential to line $g_2$

I have a problem in finding the radius and the center of a circle with the following conditions

• Circle tangential to line $$g_1$$ and going through known point $$P_1$$
• Circle is tangential to $$g_2$$

The following things I need to find:

• radius of circle $$(r)$$
• center of circle $$(x_m, y_m)$$
• coordinates of $$P_2 (x_2,y_2)$$

So far I know that because of the horizontal line the middle point of the circle need to be $$x_m = x_1$$. I then tried to continue with the equation of a circle but I have still $$2$$ unknowns ($$y_m$$ and $$r$$) because I do not know how to use the constraint of $$g_2$$.

Does anybody have a hint how to solve this problem?

Edit #1: I tried to understand the "Special cases of Apollonius' problem" with two lines and one point. Here is the current progress: But I do not know how to continue since becaues P1 is already a point on the circle/the tangent.

• First: find intersection P of g1 and g2. Second: find point P2 of g2 such that PP1=PP2. There are two such points, there are two circles, satisfying problem statement. Third: find equations of lines g3 and g4 perpendicular to g1 and g2 and passing through P1 and P2. Fourth: find intersection of g3 and g4. This is center O. Fifth: find distance OP1, which is radius. 2 days ago

Let $$P_1 = (x_1, y_1)$$. You can first find the intersection of $$g_1$$ and $$g_2$$.

Let the equation of $$g_2$$ be

$$A x + B y + C = 0$$

Set $$y = y_1$$ and solve for $$x$$, this will give you,

$$x = - \dfrac{B y_1 + C}{A}$$

Note that $$A$$ cannot be zero, because $$g_2$$ is not horizontal. If it is horizontal, then the problem becomes trivial to solve.

So now the intersection point between $$g_1$$ and $$g_2$$ is

$$P_3 = (x_3, y_3) = (- \dfrac{B y_1 + C}{A} , y_1 )$$

Find the signed distance between $$P_1$$ and $$P_2$$:

$$d = x_1 - x_3$$

Next, find the angle between $$g_1$$ and $$g_2$$. There are two possible angles. The unit normal to $$g_1$$ is $$u_1 = \langle 0, 1 \rangle$$, and the unit normal to $$g_2$$ is $$u_2 = \langle \dfrac{A}{\sqrt{A^2 + B^2}}, \dfrac{B}{\sqrt{A^2 + B^2}} \rangle$$. To get the angle right, we have to use a combination of dot product and cross product of $$u_1$$ and $$u2$$.

$$\cos(\phi_1) = u_1 \cdot u_2$$

$$\sin(\phi_1) = \bigg[ u_1 \times u_2 \bigg]_z$$

And $$\phi_1 = \text{Atan2}(\cos(\phi_1), \sin(\phi_1) )$$

Therefore, the two possible angles between $$g_1$$ and $$g_2$$ are

$$\phi_1$$ and $$\phi_2 = \pi - \cos^{-1} ( u_1 \cdot u_2 )$$

From this, it follows that the possible signed radii are

$$r_1 = d \tan \bigg( \dfrac{\phi_1}{2} \bigg)$$

and

$$r_2 = - d \tan \bigg( \dfrac{\phi_2}{2} \bigg)$$

And the center will be at

$$C_i = P_1 + (0, r_i)$$

As an example, suppose $$g_1$$ is the line $$y = 10$$, and $$g_2$$ is the line $$y = \sqrt{3} (x + 15)$$

First find the intersection point between the two lines

$$10 = \sqrt{3} (x + 15)$$ implies $$x_3 = -15 + \dfrac{10}{\sqrt{3}}$$

Suppose $$P_1 = (10, 0)$$ , then $$d = x_1 - x_3 = 25 - \dfrac{10}{\sqrt{3}}$$

$$u_1 = \langle 0, 1 \rangle$$, $$u_2 = \langle - \dfrac{\sqrt{3}}{2} , \dfrac{1}{2} \rangle$$

From this

$$\cos(\phi_1) = \dfrac{1}{2}$$

$$\sin(\phi_1) = \dfrac{\sqrt{3}}{2}$$

Therefore, $$\phi_1 = \dfrac{\pi}{3}$$

And $$\phi_2 = \pi - \phi_1 = \dfrac{2 \pi}{3}$$

From this,

$$r_1 = d \tan(\dfrac{\pi}{6} ) = (25 - \dfrac{10}{\sqrt{3}}) (\dfrac{1}{\sqrt{3}} ) = \dfrac{1}{3} ( 25 \sqrt{3} - 10 )$$

And

$$r_2 = - d \tan(\dfrac{\pi}{3} ) = - (25 \sqrt{3} - 10 )$$

Here is additional figures obtained from this algorithm.

• Wow I'm really impressed. Thank you for this great solution. One question to that. Why there is a minus sign at r2? In my understanding a radius is always unsigned?
– mk3
2 days ago
• It is so you can add the signed radius to the point $P_1$ to obtain the center $C$ as follows $C_i = P_1 + (0, r_i)$ 2 days ago
• Thanks for the explanation. Very nice solution
– mk3
2 days ago
• Just an additional question. Is this method also applicable if I have still two lines and not only P1 on g1 but also P2 on g2 is fixed? Or is this problem then overconstrained? Because now P2 is also a solution but what if it is an additional constraint?
– mk3
2 days ago
• Yes. In this case, the problem will be over-constrained. 2 days ago

If a circle is tangent to two lines, its center must be on one of the two angular bisectors of these two lines.

If a circle is touching a line in a given point, the center must be on the orthogonal line through that point, as you already found out.

This is a special case of Apollonius' problem, namely the one with two lines and one point, made even more special by the point lying on one of the lines.

• Thank you for your hint. I tried to understand what I can find there but still do not know how to continue from the line connecting P1 and P2 on. The result of my understanding you can find at Edit #1.
– mk3
2 days ago