Regarding a Line Tangent to a Circle

• Jul 13th 2012, 03:42 PM
Patio111
Regarding a Line Tangent to a Circle
Hello Math Help Forum, I'm new here, and would first of all like to say hi :)

I am currently working on a 2D Lighting Engine software, and need to be able to determine a certain point (or at least the equation of the line passing through it). Here's an illustration:

Attachment 24281

What I would like to do is, knowing the values of r, x, y, x1, and y1, to find the values of x2 and y2 in terms of these variables (note that (x2, y2) is the tangent point of the line passing through the circle, (x, y) is the center of the circle, though not necessarily (0, 0), (x1, y1) is just a random point outside of the circle, and 'r' is the radius of the circle).

I had thought of using the right triangle to find the measurement of the upper side and equate that to the distance between (x1, y1) and (x2, y2), but ended up with a very complex equation that I probably wasn't able to simplify because of lack of further knowledge.

Hope I made myself clear, thank you!
• Jul 13th 2012, 04:48 PM
Plato
Re: Regarding a Line Tangent to a Circle
Quote:

Originally Posted by Patio111
Attachment 24281
What I would like to do is, knowing the values of r, x, y, x1, and y1, to find the values of x2 and y2 in terms of these variables (note that (x2, y2) is the tangent point of the line passing through the circle, (x, y) is the center of the circle, though not necessarily (0, 0), (x1, y1) is just a random point outside of the circle, and 'r' is the radius of the circle).

There is a messy but easy solution. I will change notation to a more standard form.
Let $(a,b)$ be the external point. (you called this (x_1,y_1)).
Let $(h,k)$ be the center of the circle. (you called this (x,y)).
Let $(x,y)$ be the point of tangentany . (you called this (x_2,y_2)).

$(a-h)^2+(b-k)^2=(x-a)^2+(y-b)^2+(x-h)^2+(y-k)^2$ AND

$\frac{y-k}{x-h}=-\frac{h-a}{k-b}$.

Solve for $(x,y)$

BTW: $r^2=(x-h)^2+(y-k)^2$
• Jul 13th 2012, 05:35 PM
Patio111
Re: Regarding a Line Tangent to a Circle
Thanks for responding.

The problem is that I don't know how to solve for (x, y) once I get to

(a - h)2 + (b - k)2 = (x - a)2 + (y - b)2 + r2

By the way, shouldn't it be (y - k) / (x - h) = - (y - b) / (x - a) ?

EDIT: Actually, I think it should be (y - k) / (x - h) = - (x - a) / (y - b) because the slope or perpendicular lines has a relation of m_1 = 1 / m_2.
• Jul 14th 2012, 09:07 AM
Wilmer
Re: Regarding a Line Tangent to a Circle
• Jul 14th 2012, 11:47 AM
Patio111
Re: Regarding a Line Tangent to a Circle
Thanks! I had searched in Google already, but only found cases where the center of the circle was assumed to be the origin.
• Jul 15th 2012, 04:27 AM
Wilmer
Re: Regarding a Line Tangent to a Circle
Well, regardless, your problem really simplifies to:
Code:

B(x1,y1) a            c C            b            A(x2,y2)
Given the coordinates of A and B and the length (radius) of shorter leg BC,
calculate the coordinates of C; enough info is given to calculate b and c.
• Jul 15th 2012, 06:19 PM
Wilmer
Re: Regarding a Line Tangent to a Circle
Code:

B(f,g) a            c C(x,y)      b            A(d,e)
That's right triangle ABC; givens are sides a,b,c and coordinates d,e,f,g.
(b and c are easily calculated; so I'm using them as givens)
c = SQRT[(e-g)^2 + (f-d)^2]
b = SQRT(c^2 - a^2)

U = 180 - ASIN(b/c) - ASIN[(e-g)/c]

x = a * SIN(90-U) + f

y = a * SIN(U) + g

Try it with this "all integers" example:
a = 70 (that's the radius), d = 40, e = 250, f = 190, g = 50;
so b = 240 and c = 250.

That'll result in x = 232 and y = 106.