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.

Why are the two following calculations so dramatically different in results?

Given ATAN(y2 - y1 / x2 - x1)

Atan(165.377838 - 240 / 57.234100 - 160) = 0.8696708890423176

Atan(159.340393 - 240 / 61.901459 - 160) = -1.3538428308947705

I am calculating all of the points on a circle, and when I reach from approximately 45 to 135 degrees, rotating counterclockwise, all of my results go from positive to negative, and giving me sparatic results, such as above. The result of the arctangent, every where else in the rotation, is around a 1.43 to 1.53, but in this area they go negative and drop full integer.

Any ideas why this is happening?

share|improve this question
add comment

1 Answer

There are parentheses missing. You probably intended ATAN((y2 - y1) / (x2 - x1)).

share|improve this answer
2  
Actually, if he's doing what I think he's doing, the two-argument arctangent might be a better thing to use: atan2(y2 - y1, x2 - x1)... –  J. M. Jul 15 '11 at 3:51
1  
Without the parentheses, these are Atan(1.183) and Atan(-4.537) and I get the values quoted. But why should they be close? –  Ross Millikan Jul 15 '11 at 4:28
    
So, the answer to George's question is: you forgot the parentheses. –  GEdgar Jul 15 '11 at 13:20
add comment

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.