Skip to content
Google Sheets

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.

  1. The bearing of a point from x and y coordinates — ATAN2 keeps the quadrant:

    =DEGREES(ATAN2(B2, C2))

    Result135

  2. A compass-style 0–360° heading from two points (note x then y):

    =MOD(DEGREES(ATAN2(C2 - C1, B2 - B1)), 360)

    Result225

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.

Loading the editor…

ATAN2 errors

What they mean — and the fixes.

  • #DIV/0!

    Both coordinates are 0 — the angle is undefined at the origin.