Geometry – Equation of Angle Bisector Given Two Lines in 2D

algebra-precalculusanalytic geometrygeometrytrigonometry

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).

Best Answer

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.