# Thread: Regarding a Line Tangent to a Circle

1. ## 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:

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!

2. ## Re: Regarding a Line Tangent to a Circle

Originally Posted by Patio111

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 $\displaystyle (a,b)$ be the external point. (you called this (x_1,y_1)).
Let $\displaystyle (h,k)$ be the center of the circle. (you called this (x,y)).
Let $\displaystyle (x,y)$ be the point of tangentany . (you called this (x_2,y_2)).

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

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

Solve for $\displaystyle (x,y)$

BTW: $\displaystyle r^2=(x-h)^2+(y-k)^2$

3. ## 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.

5. ## 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.

6. ## 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.

7. ## 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.