# Arctan2 vs arctan

- Author:
- DavidK

## Motivation

Given a point (x,y) in the rectangular xy-plane, what angle, theta, does the line segment from the origin to (x,y) and the positive x-axis form? Or in other words, in which direction does the vector

**u**point? This question seems to be answered by using the arctan function. atan(y/x). However, this is only true for some points (x,y). Move the point in the following graph to find where this is true.When does arctan(y/x) give the angle theta? When point (x,y) is in ...

The angle theta and atan(b/a) are equal when the point (a,b) is in the first quadrant. In the IV quadrant atan(b/a) is negative. Having a negative angle signifies that the point is below the x axis, which is fine. Notice -45=315. When (a,b) is in the II or III quadrant arctan provides an angle that is 180 degrees off.
This is because a/b=-a/-b and -a/b=a/-b.
Now compare the angle theta with arctan2.

## arctan2 finds the angle

The function arctan2(y,x) finds the angle direction of the point (x,y) perfectly. We do not need to compensate for when x is negative (|theta|>90). The range of arctan2 is (-180,180].