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
| Parameter | Type | Required | Description |
|---|---|---|---|
y | DOUBLE | Yes | The y-coordinate (numerator) |
x | DOUBLE | Yes | The 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 VARCHAR | f2 VARCHAR | f3 VARCHAR | f4 VARCHAR |
|---|---|---|---|
| 0.7853981633974483 | 2.356194490192345 | -2.356194490192345 | -0.7853981633974483 |
On this page