atan
Use the atan() function to calculate the principal value of the inverse tangent (arctangent) of a numerical expression.
Syntax
atan(<numeric_expression>)Parameters
numeric_expression
integer, float
Yes
The numerical value for which to calculate the arctangent. Any real number is valid.
Returns
Type: float
Description: The atan() function returns the principal value of the arctangent of the input in radians. The resulting value is within the range (-π/2, π/2).
Usage notes
Input type: XQL doesn't support NaN or infinite values as input and these value types also can not be returned.
Valid Input Range: The
atan()function accepts any real number as input.Null Handling: If the input expression is
null, the function returnsnull.Radians to Degrees: The result is provided in radians. To convert the result to degrees, multiply the return value by
180 / PI().Symmetry: The function is odd, meaning
atan(-x) = -atan(x).Common Use Cases: This function is typically used within the
alterstage for geometric calculations, angle computations, and spatial analysis. For computing the angle from Cartesian coordinates, useatan2()instead.
Examples
Example 1: Calculate arctangent of literal values
Goal: Calculate the inverse tangent for specific numerical literals to see the radian results.
XQL code:
Explanation: You use atan() on three different literal values. atan(0) returns 0.0, atan(1) returns approximately 0.7854 (π/4), and atan(-1) returns approximately -0.7854 (-π/4).
Output:
0.0
0.7854
-0.7854
Example 2: Calculate arctangent from a field value
Goal: Calculate the arctangent of values stored in a specific field.
XQL code:
Explanation: This query computes the arctangent for each value in the numeric_value field and stores it in arc_tan_val. Since atan() accepts any real number, no filtering is needed.
Output:
101
0.5
0.4636
102
-2.0
-1.1071
103
100.0
1.5608
Example 3: Convert arctangent result to degrees
Goal: Calculate the arctangent and convert the result from radians to degrees.
XQL code:
Explanation: This query first calculates the arctangent in radians, then converts it to degrees by multiplying by 180 / π. For example, atan(1) in radians is approximately 0.7854, which converts to 45.0 degrees.
Output:
101
1.0
0.7854
45.0
102
-1.0
-0.7854
-45.0
103
0.0
0.0
0.0
Related articles
Datasets:
sample_xql_raw,xdr_dataXQL recipes: XQL Recipes
Was this helpful?
