ATAN2()

All functions > MATH > ATAN2()

Returns the arctangent of y/x, using the signs of both arguments to determine the quadrant.

Signatures

Two argument arctangent

Returns: Angle in radians, in (-π, π]

ATAN2(y: T, x: U) → DOUBLE
sql
ParameterTypeRequiredDescription
yTYesy coordinate
xUYesx coordinate

With:

  • T : Any numeric type
  • U : Any numeric type

Signature notes:

  • Accepts any numeric type for both arguments, including integers
  • Returns the angle from the positive x-axis to the point (x, y)
  • More accurate than ATAN(y/x) for points near the axes
  • Returns NULL if either input is NULL

Examples

FeatureQL
SELECT
    f1 := ATAN2(1.0E0, 1.0E0), -- First quadrant, 45°
    f2 := ATAN2(1.0E0, -1.0E0), -- Second quadrant, 135°
    f3 := ATAN2(-1.0E0, -1.0E0), -- Third quadrant, -135°
    f4 := ATAN2(-1.0E0, 1.0E0) -- Fourth quadrant, -45°
;
Result
f1 VARCHARf2 VARCHARf3 VARCHARf4 VARCHAR
0.78539816339744832.356194490192345-2.356194490192345-0.7853981633974483

Last update at: 2026/05/26 17:22:09