[Math] Distance between a point and a circle circumference given angle from point

circlestrigonometry

Let us assume that I have a circle with radius $r$ and centre $C$ and a point $P$. How can I find the length of the line segment starting from $P$ with a specific angle $\theta$, ending on the circumference of the circle (assuming that I chose the angle so that is the case). If the line intersects twice (that is if it is not a tangent), I want the distance to the closest point.

I know that I can easily find the angle and distance between the points, but I am not sure how it will help me. I also assume that the approach consists of finding the point where the line and circle intersects in order to find the distance between the points.

UPDATE:
$P$ can be where ever in the plane as long as it is outside the circle.
$\theta$ is measured according to the x-axis (I'm not sure that is a very accurate description, ask if you do not understand)

Best Answer

On an $x,y$ Cartesian plane, suppose we are given the coordinates of a point $C$, the radius $r$ of a circle around $C$, the coordinates of a point $P$ outside the circle, and a ray $\overrightarrow{PQ}$ starting at $P$ at an angle of $\theta$ clockwise from the $x$-axis. (The coordinates of $Q$ need not be known; it is used here just as a way to name a particular ray starting at $P$.)

Find the distance $d$ from $P$ to $C$ and the direction $\theta_0$ (clockwise from the $x$-axis) of the ray $\overrightarrow{PC}$ from $P$ through $C$. Compute the angle $\alpha$ between the rays $\overrightarrow{PQ}$ and $\overrightarrow{PC}$; it is $\lvert \theta - \theta_0 \rvert$, $\lvert \theta - \theta_0 + 2\pi \rvert$, or $\lvert \theta - \theta_0 - 2\pi \rvert$, whichever is smallest.

If $\alpha \geq \frac\pi2$ then there is no intersection, so we're done. In all of the discussion below, assume that $\alpha < \frac\pi2$.

If $M$ is the point on ray $\overrightarrow{PQ}$ closest to $C$, the triangle $PMC$ is a right triangle with a right angle at $M$ and the angle $\alpha$ at $P$. Therefore the distance $CM = d \sin \alpha$ and the distance $PM = d \cos\alpha$. (Note that we compute all of this without needing to find the coordinates of $M$.)

If $d \sin \alpha > r$ then there is no intersection. If $d \sin \alpha = r$ then the ray $\overrightarrow{PQ}$ is tangent to the circle, $M$ is the point of tangency and is one endpoint of the line segment, and the distance $PM$ is $d \cos \alpha$.

If $d \sin \alpha < r$ then ray $\overrightarrow{PQ}$ intersects the circle in two points. One of these points is between $P$ and $M$; call that point $X$. Then $XMC$ is a right triangle with hypotenuse $XC = r$ and leg $CM = d \sin \alpha$; the length of the other leg is therefore $XM = \sqrt{r^2 - d^2 \sin^2 \alpha}$. Therefore $$PX = PM - XM = d \cos \alpha - \sqrt{r^2 - d^2 \sin^2 \alpha},$$ which is the distance we were to find.

Related Question