# Line segment equation in polar coordinates

I have a line segment given by two points $A$ and $B$. $$A+u(B-A), u\in[0,1]$$

when doing calculations with this segment, it would be advantageous to have it written in polar coordinates around some point $S$. More specifically, in the form $$r=f(\phi)$$

I could brute force this expression but the result starts getting ugly, fast. Is there some insight I can use that would give me a simpler definition of $f$ using $A$, $B$ and $S$?

• What is the meaning of point $S$? Since that is not clear, I used the origin in my answer. – Rory Daulton Aug 3 '15 at 0:17
• S is supposed to be the relative origin of the polar coordinates. – Luka Horvat Aug 3 '15 at 0:22
• Is $S$ given, or can the answerer choose $S$? And are $r$ and $\phi$ then relative to $S$? – Rory Daulton Aug 3 '15 at 0:36
• S is given, and yes, $r$ and $\phi$ are relative to it. – Luka Horvat Aug 3 '15 at 10:52

Let's assume that points $A$ and $B$ are $(x_1,y_1)$ and $(x_2,y_2)$ in Cartesian coordinates and $(r_1,\theta_1)$ and $(r_2,\theta_2)$ in polar coordinates.

Then the direction angle of the line segment is given by

$$\theta_0=\begin{cases} \tan^{-1}\left(\frac{y2-y1}{x2-x1}\right), & x_1\ne x_2 \\ \frac{\pi}2, & x_1=x_2 \end{cases}$$ And the signed distance from the origin to the line containing points $A$ and $B$ is

$$d_0=r_1\sin(\theta_1-\theta_0)=r_2\sin(\theta_2-\theta_0)$$

(Use either formula for $d_0$: you get the same result.) If $d_0\ne 0$ then the line containing points $A$ and $B$ does not pass through the origin, and the polar equation of that line is

$$r=\frac{d_0}{\sin(\theta-\theta_0)}$$

and to get only the segment on the line just require that $\theta$ is between $\theta_1$ and $\theta_2$.

If $d_0=0$ then the line containing points $A$ and $B$ does pass through the origin, and thus $r$ is not a function of $\theta$ and another kind of polar equation will be required to specify the line, such as $\theta=\theta_1$ with $r$ limited to be between $r_1$ and $r_2$.

Note that the "distance" $d_0$ may be negative. If that is not desired, replace $d_0$ with $-d_0$ and $\theta_0$ with $\theta_0+\pi$ or $\theta_0-\pi$.

This diagram explains much of those formulas.

• That extremely neat. I am having trouble seeing how the formula for r is derived. – Luka Horvat Aug 3 '15 at 12:50
• @LukaHorvat: From the diagram you can see that $d_0=r_1\sin(\theta_1-\theta_0)$ (up to $\pm$). But that same will hold for any other point on the line: $d_0=r\sin(\theta-\theta_0)$, so $r=\frac{d_0}{\sin(\theta-\theta_0)}$. I left out the general point in my diagram, thinking it would just clutter the diagram. Is it clear now? – Rory Daulton Aug 3 '15 at 14:48
• Yes! Thanks for answering! – Luka Horvat Aug 3 '15 at 15:14
• Do you know any way of getting $\theta_0$ (angle or slope) without converting to Cartesian coordinates? – Fernando Pelliccioni Feb 22 '16 at 17:49
• @FernandoPelliccioni: I can see several ways, but probably the simplest is to substitute $x_1=r_1\cos\theta_1$ etc. into my formula for $\theta_0$, giving $$\theta_0=\tan^{-1}\left(\frac{r_2\sin\theta_2-r_1\sin\theta_1}{r_2\cos\theta_2-r_1\cos\theta_1}\right)$$ for the denominator non-zero, or $\pi/2$ otherwise. – Rory Daulton Feb 22 '16 at 19:05