# How to find the distance from a point outside a circle to any point on a circle.

I'm looking for a way to find out the distance from a point outside a circle to a point on a circle, where the point on the circle is based on radians, degrees, or both (whatever the formula works with).

With this, I know the distance from the point to the circle ($x$), and the radius of the circle ($r$). I also know how many degrees ($\theta$) from a starting point on the circle, which is on the line between the point outside the circle and the center of the circle.

So, I'm dealing with simple right triangles here, but what I don't know how to get is the lengths of opposite and adjacent arms given a number of degrees.

Here is an poorly drawn GIF to help understand what I want. The red line is what I'm trying to get.

A point on the circle with center $(p,q)$ is given by $(p+r\cos\theta,q+r\sin\theta)$. If you have the point outside the circle, $(x,y)$, just use the distance formula between this point and the point on the circle, i.e.
$$\text{distance} = \sqrt{(x-(p+r\cos\theta))^2 + (y-(q+r\sin\theta))^2}$$
The data of your problem is: $P=(a,b)$ outside point; $C=(c,d)$ center of circle; $r$ radius of circle. Let Q=(x,y) be your generic point and $D$ the searched distance. You have two equations to use: $$(1)....( PQ)^2=(x-a)^2+(y-b)^2= D^2$$
$$(2)....(x-c)^2+(y-d)^2=r^2$$ Hence (1)-(2) gives $$D^2=2(c-a)x+2(d-b)y+a^2+b^2-c^2-d^2+r^2$$ Where $D$ is function only of $x$ and $y$ as must be answer.