[Math] Given two lines, each defined using Hesse normal form find the intersection point.

euclidean-geometry

A line can be defined by two numbers : distance of line to origin and the angle from the origin to closest point on the line. Is there a formula to find the coordinates of intersection of two lines given this representation?

I can go to y=a*x+b representation for each line and calculate intersection point using basic algebra. However, vertical lines behave poorly. I can do a if (angle == 0 or angle == pi){.. check, but checking if two doubles are equal is pointless.

Best Answer

You can write the lines as $ax+by=c$ and $dx+ey=f.$ (This includes vertical lines.) Now, to find the intersection point you solve de system

$$\begin{cases}ax+by&=c\\ dx+ey&=f\end{cases}$$ to get

$$x=\dfrac{ce-bf}{ae-bd},\quad y=\dfrac{af-cd}{ae-bd}.$$ (Of course, this only works if the lines are not parallel.)