User Rating 0.0
Total Usage 0 times
Sine component
Cosine component
Presets:
Is this tool helpful?

Your feedback helps us improve.

About

The two-argument arctangent function atan2(y, x) computes the angle θ between the positive x-axis and the point (x, y) in the Cartesian plane. Unlike the single-argument arctan(y ÷ x), which loses quadrant information and fails when x = 0, atan2 returns the correct angle across all four quadrants in the range (π, π]. Getting the quadrant wrong in navigation, robotics, or game physics results in vectors pointing 180° opposite to the intended direction. This calculator uses the IEEE 754-compliant atan2 implementation and handles all edge cases including axis-aligned points and the origin.

This tool approximates nothing. It delegates to the native floating-point atan2 with full 64-bit double precision (~15 significant digits). Note: the result at the origin (0, 0) is implementation-defined by IEEE 754 and returns 0 in most environments, though mathematically the angle is undefined.

arctan2 atan2 inverse tangent angle calculator trigonometry unit circle radians to degrees

Formulas

The two-argument arctangent is defined as the angle θ from the positive x-axis to the vector (x, y):

θ = atan2(y, x) (π, π]

Piecewise definition used internally:

{
arctan(y÷x) if x > 0arctan(y÷x) + π if x < 0, y 0arctan(y÷x) π if x < 0, y < 0+π÷2 if x = 0, y > 0π÷2 if x = 0, y < 0undefined if x = 0, y = 0

Unit conversions from the native radian result:

θdeg = θrad × 180π
θgrad = θrad × 200π
θturns = θrad2π

Where θ is the computed angle, y is the vertical coordinate (sine component), x is the horizontal coordinate (cosine component), and π 3.14159265358979.

Reference Data

Point (x, y)Quadrantatan2 (rad)atan2 (deg)Notes
(1, 0)+x axis00°Reference direction
(1, 1)Iπ÷445°Diagonal, first quadrant
(0, 1)+y axisπ÷290°Straight up
(1, 1)II3π÷4135°Second quadrant
(1, 0)x axisπ180°Opposite of reference
(1, 1)III3π÷4135°Third quadrant
(0, 1)y axisπ÷290°Straight down
(1, 1)IVπ÷445°Fourth quadrant
(0, 0)Origin00°Mathematically undefined
(−0, 0)+y sideπ180°IEEE 754 signed zero
(3, 4)I0.927353.13°3-4-5 right triangle
(0.5, 0.866)Iπ÷360°Unit circle at 60°
(−0.707, 0.707)II3π÷4135°Unit circle at 135°
(100, 0.001)I0.000010.000573°Nearly on +x axis
(0.001, 100)I1.570889.999°Nearly on +y axis

Frequently Asked Questions

The convention atan2(y, x) follows the mathematical definition where y corresponds to the sine (opposite) and x to the cosine (adjacent) of the angle. This ordering was established in FORTRAN in the 1960s and adopted by IEEE 754, C, Java, and JavaScript. Swapping the arguments produces the complementary angle (π÷2 θ), which is a common source of bugs in rotation code.
The single-argument arctan(y÷x) returns values only in (π÷2, π÷2), covering quadrants I and IV. It cannot distinguish (1, 1) from (1, 1) since both yield y÷x = 1. Additionally, it throws a division-by-zero error when x = 0. atan2 handles all four quadrants and returns ±π÷2 on the y-axis.
Mathematically, the angle is undefined at the origin. JavaScript's Math.atan2(0, 0) returns 0 per the IEEE 754 specification. However, with signed zeros, Math.atan2(0, −0) returns π and Math.atan2(−0, −0) returns π. This calculator flags the origin as a special case in its output.
Add 360° to any negative degree result: θpositive = (θdeg + 360) mod 360. In radians, use (θ + 2π) mod 2π. This calculator displays both the standard (180 to 180) and the normalized (0 to 360) degree values.
This tool uses JavaScript's native Math.atan2, which operates on IEEE 754 double-precision (64-bit) floats. This provides approximately 15 - 17 significant decimal digits. The result is displayed to 10 decimal places. For comparison, a 1 microradian error at 1km distance corresponds to 1mm of positional drift.
atan2 is the standard in robotics (joint angle computation), game development (sprite rotation toward a target), navigation (bearing calculations from GPS deltas), computer vision (gradient orientation in edge detection like Canny), and signal processing (phase angle of complex numbers a + bi). Any domain requiring unambiguous full-circle angles mandates atan2.