[Math] Find angle between two lines

geometrytrigonometry

enter image description here

I have two lines.
I have each $X$, $Y$.
I want to find the angle between them (please mark if your method returns radians or degrees)
Aka a function $F[x, y, x_2, y_2, C_x, C_y]$ that will return their angle (at crossing point…)
While $C_x$ and $C_y$ are Cross-point $X$ and $Y$, that means they point where they touch, assuming input is OK. (in the image its the center dot)

Thank you!

Best Answer

The angle of line $2$ from the horizontal is $\text{Atan2}(y_2-C_y,x_2-C_x)$, a function supplied in most programming languages. Similarly for line $1$, the angle from the horizontal is $\text{Atan2}(y_1-C_y,x_1-C_x)$. The angle between is just the difference, but you have to worry adding or subtracting $2\pi$ as required. I am accustomed to Atan2 returning radians, but you could check your documentation.