# Circle geometry problem - distance from arbitrary point to edge

I have a rather complicated geometry problem that I want to solve involving a circle.

The problem goes like this.

Background:

A circle is centered about the origin on the x-y plane with radius $R$. The point $P$ inside the circle is located at $(x_0,y_0)$ where $x_0$ and $y_0$ are positive. A line with a positive slope is drawn connecting point $P$ to the edge of the circle (let's call the point at the edge of the circle $Q$, and the angle that such a line makes with the x-axis $\theta$).

Problem:

Express the length of $PQ$ as a function of $x_0$, $y_0$, $\theta$, and $R$.

Can anyone teach me how to solve this problem?

There is nothing unusual here: You know the slope of the line and a point it passes through: $\tan \theta$ and $(x_0,y_0)$. So the equation can be written down as $y= y_0 +m(x-x_0)$. Substitute this $y$ in the equation of circle $x^2+y^2-R^2=0$. Then you will get a quadratic in $x$. $$x^2 +[y_0+m(x-x_0)]^2-R^2=0$$ Solve it, you will get the $x$ co-ordinates of the two points of intersection points. Once you know the $x$ co-ordinate of $P$ its $y$ co-ordinate is calculated by substituting in the equation of the line.