Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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,x2,y2,Cx,Cy] that'll return their angle (at crossing point...)
While Cx and Cy 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|improve this question

1 Answer 1

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|improve this answer
    
Thank you! It seems to work. –  Quantic Programming Aug 28 '11 at 10:28

Your Answer

 
discard

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.