Equation of angle bisector, given the equations of two lines in 2D

I have two lines in 2D expressed with general equation (or implicit equation):

First line: $a_1x+b_1y=c_1 \qquad(1)$

Second line: $a_2x+b_2y=c_2 \qquad(2)$

If the two lines are intersecting I will need to find the equation of the angle bisector line.

If the two lines are parallel I will need to find the equation of the "middle" line (I do not know the "right" name for this line, maybe "medial axis"?).

For example if the two parallel lines are $x=1$ and $x=-1$ then the "middle" line will be $x=0$.

I found a snippet of code where the angle bisector line is

$(a_1+a_2)x+(b_1+b_2)y=c_1+c_2 \qquad(3)$

but I do not understand why (apart from the simple cases of vertical or horizontal parallel lines).


Solution 1:

Expanding my comment above.

For the second part of your question, which is the easier one. Two straight lines $$a_{1}x+b_{1}y=c_{1}\qquad (1)\qquad\text{ and }a_{2}x+b_{2}y=c_{2}\qquad(2)$$ are parallel if and only if $a_{1}b_{2}-a_{2}b_{1}=0$, because only then their slope $% m=-a_{1}/b_{1}=-a_{2}/b_{2}$ is the same (in other words the system of linear equations (1) and (2) has no solutions, its determinant vanishes). Let $b_{1}b_{2}\neq 0$. From $(1)$ and $(2)$ we get, respectively, $y=-\frac{ a_{1}}{b_{1}}x+\frac{c_{1}}{b_{1}}$ and $y=-\frac{a_{2}}{b_{2}}x+\frac{c_{2} }{b_{2}}$. The first line crosses the $y$-axe at $(c_{1}/b_{1},0)$, while the second, at $(c_{2}/b_{2},0)$. Since the straight line parallel to these two and equidistant to them crosses the $y$-axe at $\left( \left( c_{1}/b_{1}+c_{2}/b_{2}\right) /2,0\right) $, and has the same slope $m$, its equation is $$y=-\frac{a_{1}}{b_{1}}x+\frac{1}{2}\left( \frac{c_{1}}{b_{1}}+\frac{c_{2}}{b_{2}}\right) ,\qquad (3)$$ which is equivalent to $$a_{1}x+b_{1}y-\frac{\ c_{1}b_{2}+c_{2}b_{1}}{2b_{2}}=0 .\qquad (4)$$

Without loss of generality assume that $b_{1}=0$ and $a_{1}\neq 0$. Then $(1)$ becomes $x=c_{1}/a_{1}$ and $(2)$ should be of the form $x=c_{2}/a_{2}$, if both lines are parallel. The line equidistant to both is given by the equation $x=\left( c_{1}/a_{1}+c_{2}/a_{2}\right) /2$.

If your equations are $y=c_{1}/b_{1}$ and $y=c_{2}/b_{2}$, the line equidistant to them is given by $y=\left( c_{1}/b_{1}+c_{2}/b_{2}\right) /2$.


Added. As for the main question I got a different solution, namely, the lines whose equations are

$$\left( a_{1}\sqrt{a_{2}^{2}+b_{2}^{2}}-a_{2}\sqrt{a_{1}^{2}+b_{1}^{2}}% \right) x+\left( b_{1}\sqrt{a_{2}^{2}+b_{2}^{2}}-b_{2}\sqrt{% a_{1}^{2}+b_{1}^{2}}\right) y$$

$$=c_{1}\sqrt{a_{2}^{2}+b_{2}^{2}}-c_{2}\sqrt{a_{1}^{2}+b_{1}^{2}}\qquad \left( 5\right) $$

and

$$\left( a_{1}\sqrt{a_{2}^{2}+b_{2}^{2}}+a_{2}\sqrt{a_{1}^{2}+b_{1}^{2}}% \right) x+\left( b_{1}\sqrt{a_{2}^{2}+b_{2}^{2}}+b_{2}\sqrt{% a_{1}^{2}+b_{1}^{2}}\right) y$$

$$=c_{1}\sqrt{a_{2}^{2}+b_{2}^{2}}+c_{2}\sqrt{a_{1}^{2}+b_{1}^{2}}.\qquad \left( 6\right) $$

The distance $d$ from a point $M(x_{M},y_{M})$ to a straight line $r$ whose equation is $Ax+By+C=0$ can be derived algebraically as follows:

i) Find the equation of the straight line $s$ passing through $M$ and being orthogonal to $r$. Call $N$ the intersecting point of $r$ and $s$;

ii) Find the co-ordinates of $N(x_{N},y_{N})$;

iii) Find the distance from $M$ to $N$. This distance is $d$;

after which we get the formula

$$d=\frac{\left\vert Ax_{M}+By_{M}+C\right\vert }{\sqrt{A^{2}+B^{2}}}.\qquad (\ast )$$

The distances from $M$ to lines $(1)$ and $(2)$ are thus given by

$$d_{i}=\frac{\left\vert a_{i}x_{M}+b_{i}y_{M}-c_{i}\right\vert }{\sqrt{ a_{i}^{2}+b_{i}^{2}}}.\qquad i=1,2$$

The points $P(x,y)$ that are equidistant to lines (1) and (2) define two lines which are the solutions of $d_{1}=d_{2}$:

$$\frac{\left\vert a_{1}x+b_{1}y-c_{1}\right\vert }{\sqrt{a_{1}^{2}+b_{1}^{2}}}=\frac{\left\vert a_{2}x+b_{2}y-c_{2}\right\vert }{\sqrt{a_{2}^{2}+b_{2}^{2}}}. \qquad (\ast \ast )$$

Therefore, RHS and LHS should have the same or opposite sign:

$$\frac{a_{1}x+b_{1}y-c_{1}}{\sqrt{a_{1}^{2}+b_{1}^{2}}}=\pm \frac{a_{2}x+b_{2}y-c_{2}}{\sqrt{a_{2}^{2}+b_{2}^{2}}}.\qquad (\ast \ast \ast )$$

Equations $(5)$ and $(6)$ for the two angle bisectors follow.

Example: For $a_{1}=b_{1}=b_{2}=c_{1}=1,a_{2}=c_{2}=2$, we have $x+y=1$ and $2x+y=2$. The equidistant lines are

$$\left( \sqrt{5}-2\sqrt{2}\right) x+\left( \sqrt{5}-\sqrt{2}\right) y=\sqrt{5% }-2\sqrt{2}$$

and

$$\left( \sqrt{5}+2\sqrt{2}\right) x+\left( \sqrt{5}+\sqrt{2}\right) y=\sqrt{5}+2\sqrt{2}.$$

enter image description here

Graph of $x+y=1$, $2x+y=2$ and angle bisectors.

Solution 2:

I'd say that Américo's answer has pretty well covered the algebraic solution, but I think there's some elegance to using trigonometry here. Let's say that your two lines are $y=m_1x+b_1$ and $y=m_2x+b_2$ and that they intersect at $(x_0,y_0)$ (or, rather, that this is a point on the angle bisector). I'm not really following directly from your original problem statement, but rather just trying to give an idea of the technique.

The directed acute angles formed by the lines and the positive $x$-axis are $\theta_1=\arctan(m_1)$ and $\theta_2=\arctan(m_2)$, so the directed acute angle formed by one angle bisector and the positive $x$-axis is $\theta_3=\frac{\theta_1+\theta_2}{2}$, so it has slope $m_3=\tan\theta_3=\tan\left(\frac{\arctan(m_1)+\arctan(m_2)}{2}\right)$.

Now, an equation for this angle bisector is $y-y_0=m_3(x-x_0)$ or $$y-y_0=\tan\left(\frac{\arctan(m_1)+\arctan(m_2)}{2}\right)(x-x_0).$$ The other angle bisector would be perpendicular to this one, so it would have slope $-\frac{1}{m_3}=-\cot\left(\frac{\arctan(m_1)+\arctan(m_2)}{2}\right)$ and an equation for it would be $$y-y_0=-\cot\left(\frac{\arctan(m_1)+\arctan(m_2)}{2}\right)(x-x_0).$$

As it happens, the expression for $m_3$ can be simplified to a purely-algebraic expression (by applying trig identities, etc.): $$m_3=\frac{m_1m_2-1+\sqrt{m_1^2+1}\sqrt{m_2^2+1}}{m_1+m_2}$$

With this, the two lines become $$y-y_0=\frac{m_1m_2-1+\sqrt{m_1^2+1}\sqrt{m_2^2+1}}{m_1+m_2}(x-x_0)$$ and $$y-y_0=-\frac{m_1+m_2}{m_1m_2-1+\sqrt{m_1^2+1}\sqrt{m_2^2+1}}(x-x_0).$$

Solution 3:

Why dont you refer this link:

  • http://www.ditutor.com/line/equation_bisector.html