## Polar representation for lines

Let’s take an arbitrary point $(x_0,y_0)$ in the xy-plane, and consider all the possible lines passing through it $y_0 = mx_0 + b$. Each of these lines can be represented as $(m, b)$ subject to $b = -x_0m + y_0$ in the mb-plane. The mb-plane is called the Hough space:

The problem is when the line is vertical, $m$ is infinite and completely off the chart, not a nice property if you ask me. The solution is to use polar representation of the lines instead of slope-intercept representation.

In the figure below, AB is the line we want represent with polar coordinates $(\theta, d)$, where $d$ is the distance from the origin to the line ($CD$) and $\theta$ is angle between the x-axis and the normal vector of the line ($\angle BCD$).

Let E be an arbitrary point on AB, then $CF = GE = x$, $CG = y$, $GH = y / \tan \theta$, $CH = y / \sin \theta$, $HD = d - y / \sin \theta$, $HE = \frac{d - y / \sin \theta}{\cos \theta}$. Using the fact $GH + HE = x$, you can derive that $x\cos \theta + y\sin \theta = d$, the polar representation we were looking for.