Finding the angle between two lines meeting at one point.

109 Views Asked by At

I have $3$ points : $(x_1, y_1), (x_2, y_2)$ and $(x_3, y_3)$.

By joining these $3$ points I get $2$ lines meeting at $(x_2, y_2)$.

Now, I want to find the angle formed at the point $(x_2, y_2)$ when the lines intersect.

I have tried doing this by finding the slope $(m)$ of the two lines and then finding the angle by using the "$\tan \theta = \frac{m_1 – m_2 }{1+ m_1m_2}$" formula but I find that it doesn't work in some particular situations.

So is there any way by which I can convert the lines into vectors and then find the angle using $\cos \theta = \frac{v_1·v_2}{|v_1||v_2|}$ formula.

If not, could you please let me know any other way by which I can find the angle between the $2$ lines, even if I place the two lines in any direction.

2

There are 2 best solutions below

1
On

The vector from $(a,b)$ to $(c,d)$ is $(c-a, d-b)$

2
On

Let $\textbf{p}_1$, $\textbf{p}_2$, and $\textbf{p}_3$ denote the vectors with tips at $(x_1,y_1)$, $(x_2,y_2)$, and $(x_3,y_3)$, respectively, then the vector with initial point $(x_2,y_2)$ and terminal point $(x_1,y_1)$ is $\textbf{p}_1-\textbf{p}_2=(x_1-x_2,y_1-y_2)$. Similarly, the vector with initial point $(x_2,y_2)$ and terminal point $(x_3,y_3)$ is $\textbf{p}_3-\textbf{p}_2=(x_3-x_2,y_3-y_2)$. It follows that the angle between the vectors (and thus the lines) is

\begin{align*} \theta &= \cos^{-1}\left(\frac{(\textbf{p}_3-\textbf{p}_2)\cdot(\textbf{p}_1-\textbf{p}_2)}{||\textbf{p}_3-\textbf{p}_2||\text{ }||\textbf{p}_1-\textbf{p}_2||}\right)\\ &= \cos^{-1}\left(\frac{(x_3-x_2)(x_1-x_2)+(y_3-y_2)(y_1-y_2)}{\sqrt{(x_3-x_2)^2+(y_3-y_2)^2}\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}\right) \end{align*}