homechevron_rightStudychevron_rightMathchevron_rightGeometry

# Two argument arc tangent

The calculator gives an angle between positive axis x and the ray to the given point from point 0. The result corresponds to atan2 function, implemented in many computer languages and math libraries.

### This page exists due to the efforts of the following people:

#### Anton

Some math problems, e.g. complex number argument, require to calculate the angle between the ray to the given point and positive x semi-axis. To solve this task many computer languages, e.g. javascript, have atan2 (two argument arc tangent) function. Atan2 returns angle in the range (-π, π] in contrast to ordinal arc tangent, which result is in -π/2 .. π/2.

atan2 is based on arc tangent function, but it expects two arguments to correctly determine the result quadrant.

#### atan2

Digits after the decimal point: 2
Atan2 value on graph
Result, degrees

### Atan2 calculation algorithm

Arctan2 with all positive x is same as ordinal arc tangent:
$atan2(y,x) = \arctan\frac{y}{x}$, x>0
For other x values, arctan2 can be calculated according the following table:

y<0 y = 0 y>0
x<0 $\arctan\frac{y}{x}-\pi$ $\arctan\frac{y}{x}+\pi$ $\arctan\frac{y}{x}+\pi$
x=0 $- \frac{\pi}{2}$ undefined $\frac{\pi}{2}$
PLANETCALC, Two argument arc tangent