I want to find the intersection point of two lines where, one of the lines is parallel to y axis. I know we can find the intersection point of two line by solving the equation $y=m(x-P_x)+P_y$ where m is the slope and $(P_x,P_y)$ are the given coordinates.
but when the line is parallel to y axis, its slope is not defined. In that case, how to solve the equations and how to find the angle between those two lines?
$\endgroup$ 13 Answers
$\begingroup$Take the general form $Ax + By + C = 0$ and $A_2x + B_2y + C_2 = 0$
Then the point of intersection will be $(\frac{B*C_2 - B_2*C_1}{A*B_2-A_2*B} , \frac{C*A_2 - A_1*C_2}{A*B_2-A_2*B})$
Now take $B_2$ as zero because line is parallel to y-axis.
Thus the new point of intersection will be $(\frac{B*C_2}{-A_2*B} , \frac{C*A_2 - A_1*C_2}{-A_2*B})$ = $(\frac{-C_2}{A_2} , \frac{A_1*C_2 -C*A_2}{A_2*B})$
And to find the angle between those two lines.
In that case, the line is of the form $x = a$ for some number $a$. So the point of intersection of the two lines must satisfy this equation. In other words, the point of intersection must have an $x$-value of $a$. So just plug $x=a$ into the equation for the other line and you will get the $y$-value of the point of intersection, and then you'll be done.
$\endgroup$ $\begingroup$Intuitively (but not rigorously), you can consider the slope to be infinite. Then for the equation $y=m(x-p_x)+p_y$ to keep some meaning, you need to have $x-p_x=0$, so that $m(x-p_x)$ is indeterminate ($\infty\cdot0$) and $y$ can take any value.
Another way to look at it is to temporarily swap the two axis and work with $x=m'(y-p_y)+p_x$. Then the line is horizontal instead of vertical and you can solve with $m'=0$, i.e. $x=p_x$.
$\endgroup$