ATAN2

All functions > MATH > ATAN2

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

Signatures

Returns: Arctangent in radians (between -π and π)

ATAN2(y: DOUBLE, x: DOUBLE) → DOUBLE
sql
ParameterTypeRequiredDescription
yDOUBLEYesThe y-coordinate (numerator)
xDOUBLEYesThe x-coordinate (denominator)

Notes

  • Returns the angle from the positive x-axis to point (x, y)
  • Uses signs of both arguments to determine the correct quadrant
  • Returns values in the range (-π, π] radians
  • ATAN2(0, 1) = 0, ATAN2(1, 0) = π/2, ATAN2(0, -1) = π
  • More accurate than ATAN(y/x) for points near axes
  • Returns NULL if either input is NULL

Examples

FeatureQL
SELECT
    f1 := ATAN2(1.0e0, 1.0e0),  -- 45 degrees (first quadrant)
    f2 := ATAN2(1.0e0, -1.0e0),  -- 135 degrees (second quadrant)
    f3 := ATAN2(-1.0e0, -1.0e0),  -- -135 degrees (third quadrant)
    f4 := ATAN2(-1.0e0, 1.0e0)  -- -45 degrees (fourth quadrant)
;
Result
f1 VARCHARf2 VARCHARf3 VARCHARf4 VARCHAR
0.78539816339744832.356194490192345-2.356194490192345-0.7853981633974483

Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19