Math
ATAN2 function: calculate full 4-quadrant angles using Excel's (x, y) order
Find exact directional angles from -180 to +180 degrees from (x, y) coordinates with ATAN2—avoiding quadrant loss and Excel's (x_num, y_num) argument trap.
Critical syntax detail: Excel puts x_num FIRST, y_num SECOND
Most programming languages write atan2(y, x). Spreadsheets reverse that order: ATAN2(x_num, y_num) takes horizontal coordinate x_num first and vertical coordinate y_num second.
Unlike ATAN(y/x)—which cannot tell Quadrant I (+1, +1) apart from Quadrant III (-1, -1) because both ratios equal +1—ATAN2 inspects both signs separately to return the full circle from -180° to +180°.
| Point (x, y) | Quadrant / Axis | DEGREES(ATAN2(x, y)) |
|---|---|---|
| (1, 1) | Quadrant I (NE) | 45° |
| (-1, 1) | Quadrant II (NW) | 135° |
| (-1, -1) | Quadrant III (SW) | -135° |
| (0, 5) | Positive Y axis (x = 0) | 90° (no #DIV/0!) |
Full-quadrant direction formula
Notice how x = 0, y = 5 cleanly returns 90° without dividing by zero—solving the vertical-line failure of ATAN(y/x).
These are mathematical angles measured counterclockwise from the positive x axis, not compass bearings measured clockwise from north.
=ROUND(DEGREES(ATAN2(A2, B2)), 2)Guard the (0, 0) origin explicitly
When both x_num = 0 and y_num = 0, a zero-length vector has no defined direction. Checking AND(A2=0, B2=0) returns an explicit label.
=IF(AND(A2=0, B2=0), "Undefined origin", ROUND(DEGREES(ATAN2(A2, B2)), 2))Try the example
Use the original values or change them to test your understanding.