ATAN2 returns the angle in radians between the positive x-axis and a line from the origin to the point (x_num, y_num). It is the two-argument arctangent, so it uses both coordinates to place the angle in the correct quadrant.
=ATAN2(x_num, y_num)What does ATAN2 do?
ATAN2 is a Math and trigonometry function that converts a pair of coordinates into an angle. You give it an x value and a y value, and it tells you how far that point is rotated from the positive x-axis, measured in radians. Unlike the single-argument ATAN function, ATAN2 looks at both numbers, so it knows which quadrant the point sits in and returns an angle from -π to π.
This matters whenever a spreadsheet holds positions, directions, or movement. Office workers and students often have data such as store locations on a map, camera positions in a game, or wind direction readings, and they need the angle between two points. Doing that by hand means drawing triangles and worrying about signs; ATAN2 handles all of it in one formula.
A typical situation: a facilities team records the x and y offsets of desks from a reference wall and wants to know the bearing of each desk from that reference point. With ATAN2 they can calculate every angle in a single column, then convert to degrees for a readable report. The same pattern works for navigation, engineering, and any geometry homework involving coordinates.
When to use ATAN2
- Converting survey or map coordinates into bearings and directions.
- Working out the angle of a robot arm, camera, or sensor from its x and y position.
- Calculating wind or current direction from east-west and north-south components.
- Solving geometry and trigonometry homework that involves points on a plane.
- Finding the heading between two locations in a game or simulation.
- Rotating objects or aligning drawings in design and engineering sheets.
ATAN2 syntax
=ATAN2(x_num, y_num)| Argument | Required? | What to enter |
|---|---|---|
x_num | Required | The x-coordinate of the point. This is the horizontal distance from the origin. Example: 3 in =ATAN2(3,4). |
y_num | Required | The y-coordinate of the point. This is the vertical distance from the origin. Example: 4 in =ATAN2(3,4). |
What it returns: The angle in radians between the positive x-axis and the line to the point (x_num, y_num), from -π to π (approximately -3.14159 to 3.14159). A result of 0 means the point lies on the positive x-axis.
ATAN2 examples
1 Basic angle from a simple coordinate pair
This example finds the angle for a single point. The goal is to see how ATAN2 behaves with a familiar 3-4-5 triangle. The formula =ATAN2(B2,C2) takes the x value in B2 and the y value in C2 and returns the angle in radians. Because x is 3 and y is 4, the result is about 0.9273 radians, which is roughly 53.13 degrees. The answer appears in E2, outside the data table.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Point | X | Y | |||
| 2 | P1 | 3 | 4 | 0.927295218 | ||
| 3 |
2 Angle in degrees for a report
Radians are fine for maths, but reports usually need degrees. This example wraps ATAN2 in DEGREES so the output is easy to read. The formula =DEGREES(ATAN2(B2,C2)) first calculates the angle for x = -5 and y = 5, then converts it. Because x is negative and y is positive, the point is in the second quadrant and the angle is 135 degrees. The result is placed in E2.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Point | X | Y | |||
| 2 | P1 | -5 | 5 | 135 | ||
| 3 |
3 Bearing between two locations
Here the coordinates are offsets between a reference point and a target. The goal is to find the direction from the reference to the target. The formula =DEGREES(ATAN2(B2-A2,C2-A1)) subtracts the reference coordinates from the target coordinates to get the x and y differences, then converts the angle to degrees. With a difference of 4 in x and 3 in y, the bearing is about 36.87 degrees. The answer goes in E2.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Ref X | Ref Y | Target X | Target Y | ||
| 2 | 10 | 20 | 14 | 23 | 36.86989765 | |
| 3 |
4 Wind direction from components
Meteorologists often store wind as east-west and north-south components. This example turns those components into a direction angle. The formula =DEGREES(ATAN2(B2,C2)) uses the east-west value as x and the north-south value as y. For an east component of -2 and a north component of 2, the angle is 135 degrees, meaning the wind vector points to the north-west. The result is shown in E2.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Reading | East-West | North-South | |||
| 2 | W1 | -2 | 2 | 135 | ||
| 3 |
5 Desk bearing from a reference wall
A facilities team records desk positions as offsets from a reference corner. The goal is to calculate the bearing of each desk so the layout can be checked. The formula =DEGREES(ATAN2(B2,C2)) converts the x and y offsets into an angle in degrees. For a desk at x = 6 and y = 6, the bearing is 45 degrees, placing it diagonally from the reference. The answer is placed in E2.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Desk | X Offset | Y Offset | |||
| 2 | D1 | 6 | 6 | 45 | ||
| 3 |
Common ATAN2 errors and how to fix them
| Error | Why it happens | How to fix it |
|---|---|---|
| #VALUE! | One or both arguments are text that cannot be read as a number, such as an empty cell with a space or a label like "North". | Make sure both x_num and y_num are numeric. Remove stray text or use VALUE to convert text numbers. |
| #DIV/0! | This is rare with ATAN2, but it can appear if a dependent formula divides by a zero result from ATAN2. | Check the cells that use the ATAN2 result and guard against zero with IF or IFERROR. |
| #NAME? | The function name is misspelled, for example ATAN 2 with a space or ATAN2 written as ATAN-2. | Type =ATAN2( exactly and let Excel suggest the function name. |
| Wrong quadrant result | The x and y arguments are swapped. ATAN2 expects x first, then y, which is the opposite of some other tools. | Double-check the order: =ATAN2(x_num, y_num). If your data lists y first, reference the y column second. |
Tips for using ATAN2
- Remember the order: x first, y second. Swapping them gives the complementary angle and the wrong quadrant.
- Wrap ATAN2 in DEGREES when you need a report-friendly angle, and keep the raw radians if you are feeding another trigonometric function.
- ATAN2 returns values from -π to π. If you need a 0-to-360 bearing, add 360 to negative results with a formula such as
=MOD(DEGREES(ATAN2(B2,C2)),360). - Use cell references rather than typing numbers directly so the formula updates when coordinates change.
- Test with a known point such as (1,0) which should return 0, and (0,1) which should return π/2, to confirm your argument order.
Frequently asked questions
What is the difference between ATAN and ATAN2?
ATAN takes one number and returns an angle between -π/2 and π/2, so it cannot tell which quadrant the point is in. ATAN2 takes both x and y and returns an angle from -π to π, placing the point in the correct quadrant.
Why does ATAN2 return a negative number?
ATAN2 returns negative angles for points below the x-axis, between 0 and -π. That is normal. Convert to a 0-to-360 bearing with =MOD(DEGREES(ATAN2(x,y)),360) if you need a positive value.
Does ATAN2 use degrees or radians?
ATAN2 always returns radians. Use the DEGREES function to convert the result to degrees.
Can ATAN2 handle zero coordinates?
Yes. =ATAN2(0,1) returns π/2 (90 degrees) and =ATAN2(1,0) returns 0. Both arguments can be zero only if you accept an undefined direction, which Excel returns as 0.
Related functions
Every example on this page was recalculated by SheetSkill’s spreadsheet engine. ATAN2 reference