Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am trying to find the centre and radius of a circle passing through a known point, and that is also tangential to two known lines. The only knowns are:

  • Line 1 (x1,y1) (x2,y2)
  • Line 2 (x3,y3) (x4,y4)
  • Known Point (xp,yp)

From that I need to calculate the centre of the circle (x,y).

Any help would be greatly appreciated.



share|improve this question
This is a special case of the Apollonius problem so there are typically two solutions (unless the point lies on one of the lines, or the lines are parallel and the point is not between them, or the lines are not distinct). Clearly the circles' centres lie on a line halfway between the original two lines (an angle bisector if they cross). –  Henry Jun 7 '11 at 12:11
add comment

4 Answers

The circle's center would be at the intersection of a line L and a parabola P.

The line L comes from being equidistant from your line 1 and line 2. If these intersect, take the (two) angle bisectors through that point of intersection as line L. If line 1 and line 2 are parallel, take line L to be the parallel line halfway between them.

For parabola P take your known point (xp,yp) that the circle passes through as the focus and say line 1 (or line 2 if convenient) as your directrix. That is, the center of the circle will be equidistant from the known point (xp,yp) and the point of tangency to the directrix, which amounts to affirming the eccentricity 1 of a parabola.

Note that unless the directrix is parallel to an axis, the parabola will be in "general position", which means the equation will be messier than necessary. It probably pays to translate and rotate the coordinates so that the directrix is parallel to (say) the x-axis, and for that matter so that the focus and directrix are equidistant from the origin (so that the parabola will pass through the origin and have a simple form $y = ax^2$).

Added: Since the known point (xp,yp) must lie on the same side of lines 1 and 2 as the circle and its center, choose line L through the intersection of lines 1 and 2 so that it also extends into that portion of the plane.

share|improve this answer
add comment

The first thing to note is that if you specify two lines and a point, then there are two circles that pass through the point and are tangent to the lines. We can confirm this with a little math:

Let the lines be $x + ut$ and $x+vt$ where $x$ is a general point, $u$ and $v$ are unit vectors and $t$ is a real number, so that the lines cross at $x$ (the case where the lines are parallel can be treated separately). Then the line on which the centre of a circle which is tangent to both lines can lie is given by

$$x + \frac{u+v}{2} t$$

We also require that the circle goes through the point $y$, so we need the $t$ such that

$$|| x + \frac{u+v}{2}t - y||^2 = r(t)^2$$

where $r(t)$ is the radius of the circle, given by $r=t\tan(\theta/2)$, where $\theta$ is found from $\cos\theta = u\cdot v$ (draw a diagram and you'll see where this expression comes from). Expanding this out, we get

$$||x-y||^2 - (u+v)\cdot(x-y)t + \frac{1}{4}||u+v||^2 t^2 = t^2\tan^2(\theta/2)$$

which is a quadratic equation for $t$. Solving it gives the the values of $t$ corresponding to the two possible circles.

share|improve this answer
add comment

The following is another solution that uses "analytic geometry," at a lower level of technical sophistication. The downside is that the equations look uglier and less structured than they could be.

We will use the not very hard to prove fact that if a line has equation $ax+by+c=0$, then the perpendicular distance from $(u,v)$ to the line is $$\frac{|au+bv+c|}{\sqrt{a^2+b^2}}.$$ Note that in the numerator we have an absolute value. That will cause some headaches later.

(The formulas that follow would look simpler if we adjusted the equation of any line $ax+by+c=0$ by dividing each coefficient by $\sqrt{a^2+b^2}$, but we will not do that.)

Given two points on each of our lines, we can find equations for the lines. Suppose that these equations turn out to be $$a_1x+b_1y+c_1=0\qquad\text{and}\qquad a_2x+b_2y+c_2=0.$$

Let $(u,v)$ be the center of the circle, and let $r$ be its radius. Then from the "distance to a line" formula, we have $$\frac{a_1u+b_1v+c_1}{\sqrt{a_1^2+b_1^2}}=\pm r \qquad\text{and}\qquad \frac{a_2u+b_2v+c_2}{\sqrt{a_2^2+b_2^2}}=\pm r.$$

Unfortunately that gives in general $4$ possible systems of two linear equations, which correspond to the generally $4$ (in the parallel case, $3$) pieces into which the lines divide the plane. At the end of this post are some comments about how to identify which signs to choose.

But suppose for now that we have identified the two relevant equations. We can use them to "eliminate" $r$, and obtain a linear equation $ku+lv+m=0$ that links $u$ and $v$.

Since $(u,v)$ is the center of the circle, and $r$ is the radius, we have $$(u-x_p)^2+(u-y_p)^2=r^2.$$

Use one of our linear expressions for $r$ to substitute for the $r^2$ term. We obtain a quadratic equation in $u$ and $v$. Use the equation $ku+lv+m=0$ to eliminate one of the variables. We are left with a quadratic equation in the other variable. Solve.

Note that in general we will get two solutions, since, almost always, there are two circles that work, a small circle with $(x_p,y_p)$ on the other side of the circle from where the two given lines meet, and a big circle with $(x_p,y_p)$ on the near side of the circle from where the two given lines meet.

Sign issues: It remains to deal with how to choose the $\pm$ signs in the distance equations. One approach that works reasonably well is, in our line equations $a_ix+b_iy+c_i=0$, always to choose the coefficient of $y$ to be positive. (This can be done unless the line is vertical.) Then if $a_1x_p+b_1y_p+c_1$ is positive, use $(a_1x_p+b_1y_p+c_1)/\sqrt{a_1^2+b_1^2}=r$, and if it is negative use $-r$. Do the same with the other line. The reason this works is that that if the coefficient of $y$ is positive, then $a_ix+b_iy+c_i$ is positive for fixed $x$ and large $y$. So if $a_ix_p+b_iy_p+c_i$ is positive, then $(x_p,y_p)$ lies "above" the line, and if $a_ix_p+b_iy_p+c_i$ is negative, then $(x_p,y_p)$ lies below the line.

share|improve this answer
add comment

A ruler+compass solution would be to bisect the angle between the two lines (assuming they intersect), draw any circle (with center on the bisector, and radius gotten by projecting the center orthogonally to one of the two lines) tangent to the two lines. Most likely it won't hit the point, but a simple homothety transformation will fix that.

share|improve this answer
Very nice! And it shouldn't be too hard to turn this into a coordinate-based solution. –  Isaac Jun 8 '11 at 4:51
Thanks, Isaac. This is essentially the way I solved Apollonius' problem in my somewhat distant youth: 1) enlarge the radii of the 3 circles by the same amount (won't change the center of the tangenting circle) so that two of them intersect. 2) invert the whole picture w.r.t. that point of intersection so that you have two lines and a third circle. 3) shrink that circle to a point (and parallel translate the lines correspondingly) to reduce to the problem at hand. 4) Solve this problem, and revert steps 3, 2, and 1 (recall that inversion preserves osculation). –  Jyrki Lahtonen Jun 8 '11 at 6:00
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.