Calculate the slope of a line passing through the intersection of two lines Let say I have this figure,

I know slope $m_1$, slope $m_1$, $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$. I need to calculate slope $m_3$. Note the line with $m_3$ slope will always equally bisect line with $m_1$ slope and line with $m_2$.

Suppose $m_1$ is $\tan(x)$ and $m_2$ is $\tan(y)$. We basically want 
$$
\begin{eqnarray}
\tan((x+y)/2) &=& (1-\cos(x+y))/\sin(x+y)\\
& =& (1-(\cos(x)\cos(y) - \sin(x)\sin(y)))/(\sin(x)\cos(y) + \cos(x)\sin(y))
\end{eqnarray}
$$
This is easy as $\sin(x) = m_1/\sqrt{1+m_1^2}, \cos(x) = 1/\sqrt{1+m_1^2}$, and similarly for $y$. Call $\sqrt{1+m_1^2} = n_1$ and similarly $n_2$ for $m_2$.
$$m_3 = (1-(1/n_1n_2 - m_1m_2/n_1n_2)/(m_1/n_1n_2 + m_2/n_1n_2) 
= (n_1n_2 + m_1m_2 - 1)/(m_1+m_2)$$
So $m_3 = \left(\sqrt{(1+m_1^2)(1+m_2^2)} + m_1m_2 - 1\right)/(m_1 + m_2).$
You can easily check that if $m_2 = m_1$, then $m_3 = m_1$ here. Looks legit.
