![]() |
![]() |
![]() |
Math wizards - look in here! I'm a self admitted Math 'tard (TM)
Captain Offshore
Trigonometry!
Yup.
Has this been offshored to you Captain Offshore?
Matthew Lock
First find the slope of the line. Then the angle that the line makes with the x-axis (you weren't clear about what angle you wanted, but I think you probably meant the angle with the x-axis) is the inverse tangent of the slope. If your two points are (x1,y1) and (x2-y2), then the angle is given by
Kent
Kent - Thanks!
Captain Offshore
The line L is defined by two points (x1, y1), (x2, y2).
Kalani
There I went and took too long to post while you got an answer. Go ahead and use the atan method, it's cheaper. Just remember SOHCAHTOA for the trig functions (Sine: Opposite / Hypotenuse, Cosine: Adjacent / Hypotenuse, Tangent: Opposite / Adjacent).
Kalani
Kalani , Thanks for your input - I appreciate your detailed response.
Captain Offshore
If I remember correctly (ha -- trig was just last term, and already I've forgotten this), the arctan function is only defined for half of the unit circle...so it may not give accurate results for all sets of two points.
Sam Livingston-Gray
The basic problem with arctan is that it returns a value in the range -90 to +90, and can't distiguish between angles 180 degrees apart - eg if y2-y1 = -1, and x2-x1=-1, it will return a value of 45 degrees instead of the true answer of 235. Also you have to be careful if x1=x2, when the division will fail.
as
SOHCAHTOA
injun chief
The arctan function is the inverse of the tan function.
Math Geek
If you're coding in C, use the atan2 function, not atan. It does most of the hard work for you.
Tom Payne
Use atan, just be careful in the case that x1 == x2 (you'll end up dividing by zero, you naughty boy).
Alyosha`
|