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
| Parameter | Type | Required | Description |
|---|---|---|---|
y | T | Yes | y coordinate |
x | U | Yes | x coordinate |
With:
T: Any numeric typeU: 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 VARCHAR | f2 VARCHAR | f3 VARCHAR | f4 VARCHAR |
|---|---|---|---|
| 0.7853981633974483 | 2.356194490192345 | -2.356194490192345 | -0.7853981633974483 |
On this page