Largest circle between lines through point

361 Views Asked by At

Calculate circle through a point, with its center on a line

I am trying to make a program in java that calculates the largest circle between two tangential lines through a point that is not on one of the lines.

Circle through point between intersecting lines

I have the coordinates of A, B, C and D (the point where the circle goes through), the angle between AB and AC and I already know how to get the bisector. If I could calculate the centers of both circles, I could calculate their radii, so I know which circle is the biggest.

So my question is: How can I get the coordinates of the center of both circles?

4

There are 4 best solutions below

0
On BEST ANSWER

Suppose that the given lines make an angle of $2\theta$ at their intersection, $O$, and that the given point, $P$, is such that $\overline{OP}$ makes an angle of $\phi$ with the angle bisector. (We'll assume $-\theta \leq \phi \leq \theta$.) Define $p := |OP|$. Let the circles be tangent to one of the lines at $S$ and $T$, and let $M$ be the midpoint of $\overline{ST}$. Let $P^\prime$ and $M^\prime$ be the reflections of $P$ and $M$ in the bisector. Finally, let $R$ and $R^\prime$ be the feet of perpendiculars from $P$ to the lines, as shown.

Note that $\overleftrightarrow{PP^\prime}$ is the radical axis of the two circles, which necessarily passes through $M$ and $M^\prime$.

enter image description here

Now, by simple trigonometry,

$$|OM| = |OM^\prime| = |ON|\sec\theta = |OP| \cos\phi\sec\theta = p\cos\phi\sec\theta \tag{1}$$ Also, $$\begin{align} |MP\phantom{^\prime}|\phantom{=|PM^\prime|}\; &= |PR\phantom{^\prime}|\sec\theta = |OP|\sin(\theta+\phi)\sec\theta = p\sin(\theta+\phi)\sec\theta \\ |MP^\prime| = |PM^\prime| &= |PR^\prime|\sec\theta = |OP|\sin(\theta-\phi)\sec\theta = p\sin(\theta-\phi)\sec\theta \end{align} \tag{2}$$

By the power of a point theorems, we can express the power of $M$ with respect to the "bigger" circle in two ways: $$|MT|^2 = |MP||MP^\prime| \quad\to\quad |MT|=p\sec\theta\;\sqrt{\sin(\theta+\phi)\sin(\theta-\phi)} \tag{3}$$

We see, then, that tangent point $T$ is the point on the line such that $$|OT|= |OM|+|MT| = p\sec\theta\left(\;\cos\phi + \sqrt{\sin(\theta+\phi)\sin(\theta-\phi)}\;\right) \tag{4}$$

Finally, the perpendicular at $T$ meets the angle bisector at $T_\star$, the center of the bigger circle, and we have

$$\begin{align} |OT_\star| &= |OT|\sec\theta = p \sec^2\theta\;\left(\;\cos\phi + \sqrt{\sin(\theta+\phi)\sin(\theta-\phi)}\;\right) \\ |TT_\star| &= |OT|\tan\theta = p \sec\theta\tan\theta \;\left(\;\cos\phi + \sqrt{\sin(\theta+\phi)\sin(\theta-\phi)}\;\right) \end{align} \tag{$\star$}$$

giving the location of the center, and the radius, of the bigger circle. $\square$


Observe that the various trig values are all readily calculated via vector methods.

Write $u$ and $v$ for unit direction vectors of the lines, and $w$ for the unit direction vector of the bisector (ie, $w=(u+v)/|u+v|$). And let $q$ be the vector $\overrightarrow{OP}$ (I want to call it $p$, but that's in use for the length of that vector); if we distribute $p$ across the expressions in $(\star)$, we don't have to bother "unitizing" $q$.

$$p\cos\phi + \sqrt{p\sin(\theta+\phi)\,p\sin(\theta-\phi)} = q\cdot w + \sqrt{|u\times q|\,|q\times v|}$$ $$\sec^2\theta = \frac1{\cos^2\theta} = \frac{1}{(u\cdot w)^2} \qquad \sec\theta\tan\theta = \frac{\sin\theta}{\cos^2\theta} = \frac{|u\times w|}{(u\cdot w)^2}$$

0
On

Let $a=\tan x$ be the slope of line $AB$. Let $G=(G_x,G_y)$ be the point of contact between the larger circle and the line $AB$ (so that $G_y=aG_x$). Then $E=(E_x,0)$, where $E_x=aG_y+G_x$ (because $GE$ is perpendicular to $AB$, so its slope is $-1/a$).

We have $|GE|^2=|DE|^2$, so $$(E_x-G_x)^2+(E_y-G_y)^2=(E_x-D_x)^2+(E_y-D_y)^2$$ $$(aG_y)^2+G_y^2=((aG_y+G_x)-D_x)^2+D_y^2$$ $$(a^2+1)G_y^2=((a^2+1)G_x-D_x)^2+D_y^2$$ $$(a^2+1)a^2G_x^2=((a^2+1)G_x-D_x)^2+D_y^2$$

The quantities $a,D_x,$ and $D_y$ are all known, so this is just a quadratic equation in $G_x$. Solve it, and take the larger of the two solutions. This will give you immediately $G_y=aG_x$ and $E_x=aG_y+G_x$.

4
On

Formula

The distance of the point to the apex I call $d$, and the component along the bisector $x$. The distance of the bisector is $y$ and thus $d^2 = x^2 + y^2$. The half angle (between AC and the bisector) is $ \varphi$.

The radius of the tangent circles through the point is

$$ \boxed{ r = \begin{cases} \dfrac{\sin \varphi}{\cos^2 \varphi} \left( x + \sqrt{ x^2 - d^2 \cos^2 \varphi} \right) \\ \dfrac{\sin \varphi}{\cos^2 \varphi} \left( x - \sqrt{ x^2 - d^2 \cos^2 \varphi} \right) \end{cases}} $$

How?

Development

pic

  1. Consider the big triangle BAG above, with known apex angle $\varphi$. You can write $$ \sin \varphi =\frac{r}{x+z} $$
  2. Now consider the smaller triangle DGE above. You can write $$ r^2 = y^2 + z^2 $$

    • Given : What is known is $\varphi$, $x$ and $y$.
    • Find : What can be calculated from the two equations above is $r$ and $z$.
    • Step 1 : Solve equation 1. above for $z$ $$ z = \frac{r}{\sin \varphi}-x $$
    • Step 2 : Substitute $z$ into equation 2. and solve for $r$ $$ r^2 = y^2 + \left( \frac{r}{\sin \varphi}-x \right)^2 $$

    $$ -r^2 \cot^2 \varphi = - \frac{2 r x}{\sin \varphi} + x^2 + y^2 $$

    Substitute $d^2 = x^2 + y^2$ and multiply both sides with $\sin^2\varphi$

    $$ r^2 \cos^2 \varphi = 2 r x \sin\varphi - d^2 \sin^2 \varphi $$

    Solve for $r$

    $$ r = \frac{\sin \varphi}{\cos^2 \varphi} \left( x \pm \sqrt{ x^2 - d^2 \cos^2 \varphi} \right) $$

Example:

$$\begin{aligned} x &= 8.5523 \\ y & = 2.7469 \\ \varphi & = 27.2667° \\ \hline r & = 6.7402231186653915 \\ z & = 6.1550912324182015 \end{aligned} \checkmark $$

pic

Practical Example w/ Algo

Consider the situation below and the code the goes with it. The result of the code C# (embedded in the comments) is identical to the GeoGebra calculations

geo

public enum CircleChoice
{
    Smallest,
    Largest
}
static class Program
{
    static void Main(string[] args)
    {
        // Example for answer: https://math.stackexchange.com/a/2975562/3301
        var A = new Vector2(-2.45f, -2.71f);
        var B = new Vector2(8.9222f, -3.1959f);
        var C = new Vector2(8.4971f, 6.5775f);
        var D = new Vector2(2.95f, 1.25f);

        var r_max = GetTangentCircleThroughPoint(A, B, C, D, CircleChoice.Largest);
        // r_max = 3.2795992264835716

        var r_min = GetTangentCircleThroughPoint(A, B, C, D, CircleChoice.Smallest);
        // r_min = 2.09536400590215
    }

    /// <summary>
    /// Find the radius of the largest (or smallest) circle that is tangent to
    /// two lines and is passing through a point.  
    /// Answer to question https://math.stackexchange.com/q/2975304
    /// </summary>
    /// <param name="A">The apex point</param>
    /// <param name="B">A point on one line</param>
    /// <param name="C">A point on the other line</param>
    /// <param name="D">The target point</param>
    /// <returns>The radius value</returns>
    static double GetTangentCircleThroughPoint(Vector2 A, Vector2 B, Vector2 C, Vector2 D, CircleChoice circle = CircleChoice.Largest)
    {
        // Get the half-angle between the two lines
        var apex_angle = 0.5*GetAngleBetweenVectors(B - A, C - A);
        // θ = 0.3731322286751852r = 21.378901903398422°

        // Get the direction vectors from A to B, and from A to C
        var dir_B = Vector2.Normalize(B - A);
        var dir_C = Vector2.Normalize(C - A);

        // Bisector direction is average of the two above vectors
        var bisector_dir = Vector2.Normalize( (dir_B + dir_C) / 2 );
        // Bisector othogonal from 90° rotation
        var bisector_otho = new Vector2(-bisector_dir.Y, bisector_dir.X);

        // Measure distance between A and D, along bisector (x), and away (y).
        var x = Vector2.Dot(D - A, bisector_dir);
        // x = 6.39269924
        var y = Vector2.Dot(D - A, bisector_otho);
        // y = 1.99373889

        // Hypotenouse of (x,y) distances
        var d = Math.Sqrt(x * x + y * y);
        // Intermediate values for trig of half-angle
        var sin = Math.Sin(apex_angle);
        var cos = Math.Cos(apex_angle);

        if (circle == CircleChoice.Largest)
        {
            // This is the largest circle radius
            return sin / (cos * cos) * (x + Math.Sqrt(x * x - (d * cos) * (d * cos)));
        }
        else
        {
            // This is the smallest circle radius
            return sin / (cos * cos) * (x - Math.Sqrt(x * x - (d * cos) * (d * cos)));
        }
    }
    /// <summary>
    /// Return the angle between two 2D vectors
    /// </summary>
    /// <returns>Angle in radians</returns>
    static double GetAngleBetweenVectors(Vector2 A, Vector2 B)
    {
        // dot(A,B) = norm(A)*norm(B)*cos(angle)
        // norm(cross(A,B)) = norm(A)*norm(B)*sin(angle)
        var cos = Vector2.Dot(A, B);
        var sin = -A.Y * B.X + A.X * B.Y;
        // Convention: atan2(dy, dx)
        return Math.Atan2(sin, cos);
    }
}
0
On

This can be solved using right triangle trigonometry and a quadratic equation.

I have taken the liberty to relabel your angle $x$ as angle $\alpha$. There are only two circles passing through point $D$ and tangent to the two lines, and you want the larger of the two. When we get to the solution of the quadratic equation, this will amount to taking the 'plus' option of the 'plus or minus' in the solution.

Largest circle containing D tangent to two intersecting lines

To specify the largest circle containing $D$ we need to know the distance $h$ of $E$ from $A$ and the radius $r=ED=EG$ of the circle. For these two unknown quantities, we have readily available two equations.

From $\triangle AGE$ we have

$$ r=h\sin\alpha \tag{1}$$ From the equation of a circle we have $$ r^2=(x-h)^2+y^2\tag{2} $$

Combining the two gives

$$h^2\sin^2\alpha=(x-h)^2+y^2$$

which can be re-arranged (using the identity $1-\sin^2\alpha=\cos^2\alpha$) into a quadratic equation in $h$:

$$ \left(\cos^2\alpha\right)h^2-2xh+\left(x^2+y^2\right)=0 $$

Using the quadratic formula and a bit of trigonometric simplification

$$ h=\frac{x+\sqrt{x^2\sin^2\alpha-y^2\cos^2\alpha}}{\cos^2\alpha} \tag{3}$$

This value may be substituted into equation (1) to find $r$.

Here is a link to a Geogebra Applet using the equations for $h$ and $r$ given above. You can change the angle $\alpha$ by moving the point $B$ and you can also move the point $D$.