I've been working on an algorithm that includes a step in which it has to calculate the angle between two 2D lines.

I've done some research and I've found this formula:

$\tan \theta = \pm \frac{m_2 - m_1}{1 + m_1m_2}$,

in which $m_1$ and $m_2$ are the slopes of the lines written in the form $y = mx + b$.

I also found this formula:

$\tan \theta = \pm \frac{A_2 B_1 - A_1 B_2}{A_1 A_2 + B_1 B_2}$,

in which $A_1, A_2, B_1, B_2$ are the parameters of the lines written in the form $Ax + By + C = 0$.

According to one book I've found, both formulas are equivalent. I've tried to prove that they're equivalent, but haven't managed to get it right so far.

Can someone please point me in the right direction so I can prove that both formulas are equivalent?


1 Answer 1


Put the equations $A_1 x + B_1 y + C_1 = 0$ and $A_2 x + B_2 y + C_2 = 0$ into the form $y = mx + b$ to find $m_1$ and $m_2$ in terms of $A_1$, $B_1$, $A_2$, and $B_2$, then put those into $\tan \theta = \pm \frac{m_2 - m_1}{1 + m_1m_2}$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.