ATAN2 function in Google Sheets
Returns the angle between the x-axis and a line segment from the origin (0,0) to specified coordinate pair (`x`,`y`), in radians.
=ATAN2(x, y)ATAN2 syntax and parameters
Two arguments, two required.
- xnumberRequired
The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.
- ynumberRequired
The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.
ATAN2 examples
Formulas you'll actually reuse.
The bearing of a point from x and y coordinates — ATAN2 keeps the quadrant:
=DEGREES(ATAN2(B2, C2))Result
135A compass-style 0–360° heading from two points (note x then y):
=MOD(DEGREES(ATAN2(C2 - C1, B2 - B1)), 360)Result
225
ATAN2 in Excel
Same name — your formula ports as-is.
Try ATAN2 in the playground
Edit the example — nothing to install.
Preloaded with the ATAN2 formula from Example 1 — change anything and watch it respond.
ATAN2 errors
What they mean — and the fixes.
#DIV/0!Both coordinates are 0 — the angle is undefined at the origin.
Related functions
More ways Google Sheets gets this done.
- ABSReturns the absolute value of a number.MathExcel
- ACOSReturns the inverse cosine of a value, in radians.MathExcel
- ACOSHReturns the inverse hyperbolic cosine of a number.MathExcel
- ACOTReturns the inverse cotangent of a value, in radians. .MathExcel
- ACOTHReturns the inverse hyperbolic cotangent of a value, in radians. Must not be between -1 and 1, inclusive..MathExcel
- ASINReturns the inverse sine of a value, in radians.MathExcel