Given a point and circle, what's the equation of the line that is tangent? Consider a point P (with some high y value) and a circle down below it somewhere. I want the line that extends from P and connects with the circle at tangent from the clockwise direction (if you stuck a line out from P and rotated it until it hit). I am having some trouble getting the equation. I know how to get the line with two points, but not when I only know of tangency from a certain direction.
 A: Hints:
Well, just define a general line through $\;P(x_0,y_0)\;$ :
$$y-y_0=m(x-x_0)$$
And now check when a point of this line is at a distance equal to the circle's radius from its center: if the circle is $\;(x-h)^2+(y-k)^2=r^2\;$ , solve
$$(x-h)^2+(m(x-x_0)+y_0-k)^2=r^2$$
You get many options, but you actually want the ones yielding tangent lines to the circle. For those, you'll have to check when the line is perpendicular to the circle's radius at the intersection point..
A: You have a circle with center $(h, k)$ and radius $r$.  Its equation is
$$(x-h)^2 + (y-k)^2 = r^2.$$
You have a point $P_1$ = $(x_1, y_1)$ somewhere outside the circle.
The equation of the line connecting $P_1$ to another point $P_2 = (x_2, y_2)$ is
$$y - y_1 = \frac{y_2 - y_1}{x_2 - x_1}(x - x_1).$$
Now, there are two conditions that $P_2$ must meet.  First, $P_2$ must lie on the circle.  This implies that:
$$(x_2 - h)^2 + (y_2 - k)^2 = r^2.$$
Second, the line connecting $P_1$ and $P_2$ must be tangent to the circle, so the slope of the line connecting the center of the circle and $P_2$ must be the negative reciprocal of the slope of the line connecting $P_1$ and $P_2$:
$$\frac{y_2 - k}{x_2 - h} = \frac{x_1 - x_2}{y_2 - y_1}.$$
The last two equations can be solved for two unknowns $x_2$ and $y_2$ in terms of $h, k, r, x_1,$ and $y_1$.  Solve for one of the unknowns in terms of the other in the second equation.  Substitute into the equation for the circle.  Since this has squared terms in it, you'll get two answers; pick the one you want.
Then use this unknown to solve for the other in the second equation.
Once you know $x_2$ and $y_2$, from the second equation above you have the equation for a tangent line through $(x_1, y_1)$.
A: Fleshing out the comment to Don's answer. Assume that your point is $P=(x_0,y_0)$, and that the circle has center at $(h,k)$ and radius $r$. Let $y-y_0=m(x-x_0)$
be an arbitrary line through $P$ (we can check the vertical line with infinite slope separately). In the "standard" form the equation of the line with slope $m$ is
$$
0=mx-y-(m x_0-y_0).
$$
It is known from high school analytic geometry, that the distance from a point $(x_1,y_1)$ to the line $Ax+By+C=0$ is
$$
d=\frac{|Ax_1+By_1+C|}{\sqrt{A^2+B^2}}.
$$
Here we want (tangency) $d=r$, so we get the equation ($A=m, B=-1, C=-(mx_0-y_0)$):
$$
r=\frac{|(mh-k)-(mx_0-y_0)|}{\sqrt{m^2+(-1)^2}}.
$$
Squaring this allows us to rid both the absolute values and the square roots, so do that and multiply by $m^2+1$ to get
$$
r^2(m^2+1)=(m[h-x_0]-[k-y_0])^2.
$$
Everything except $m$ is known here, and this is a quadratic equation in $m$, so you can solve for it (leaving that to you). If $h-x_0=\pm r$, then the quadratic terms cancel, and you only get a single solution. But the condition $h-x_0=\pm r$ implies that a vertical line through $(x_0,y_0)$ will also be tangent to the circle.
