I am trying to use atan2 to calculate the angle between two points. With atan2, angles increase counterclockwise, and zero is to the right i.e. The angle originates at positive x, increases up into positive y, swinging round to 180 degrees.

I am using a coordinate system where the "up" axis is actually negative, so values decrease going up the y axis instead of increase. Additionally my x-axis could flip where the right becomes negative.

Is there any easy way to account for my non-standard axis, either in the angle output or to standardise the coordinates before I call atan2?

  • $\begingroup$ try $X=-x$ and $Y=-y$ $\endgroup$ – John Joy Oct 17 '15 at 14:44
  • $\begingroup$ Oh, so I just need to negate the values of the point difference before calling atan2 and that's it?! $\endgroup$ – GenericJoe Oct 17 '15 at 17:57
  • $\begingroup$ Perhaps thats all you need to do, although, depending upon the application you may need to shift the origin up or down (or left or right) or stretch or compress the coordinates. For some applications, you also need to rotate the axes. $\endgroup$ – John Joy Oct 17 '15 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.