What is the equivalent of tan-1(theta) [inverse tangent] in Java?

Recommended Answers

All 6 Replies

That thread asked the exact question I need an answer to actually and that atan2 function looks promising. But I cant get it to work. Here is a better question for my needs: I have two points, (x1,y1) and (x2,y2) and I need to get their angle in degrees clockwise from pure "North". How do I do this?

If I remember correctly, atan() takes radiant value, not degree. The atan2() takes the diff of y and diff of x (y2-y1, x2-x1).

Taywin's right - the Math trig functions work in radians, not degrees (2*Pi radians = 360 degrees). Also I think zero angle is pure "East" (is along the x axis), not North.

... and I think the angles increase anti-clockwize as well

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.