Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|cite|improve this question
up vote 4 down vote accepted

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.

share|cite|improve this answer
Thank you! It seems to work. – Mark Segal Aug 28 '11 at 10:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.