Skip to main content

ATAN2 (SQL)

A scalar numeric function that takes two coordinates and returns the arc-tangent angle in radians.

Synopsis

{fn ATAN2(y,x)}

Description

ATAN2 takes the Cartesian coordinates of a ray (y,x) and returns the inverse (arc) of the tangent of an angle as a floating point number. The signs of both coordinates are used to determine the Cartesian coordinate. When x is a positive value, ATAN2 returns the same value as ATAN(y/x). ATAN2 returns NULL if passed a NULL value. ATAN2 treats nonnumeric strings, including the empty string (''), as the numeric value 0.

ATAN2 returns a value with a precision of 36 and a scale of 18.

ATAN2 can only be used as an ODBC scalar function (with the curly brace syntax).

You can use the DEGREES function to convert radians to degrees. You can use the RADIANS function to convert degrees to radians.

Arguments

y

A numeric expression specifying the y axis coordinate.

x

A numeric expression specifying the x axis coordinate.

ATAN2 returns either the NUMERIC or DOUBLE data type. If numeric-expression is data type DOUBLE, ATAN2 returns DOUBLE; otherwise, it returns NUMERIC.

Example

The following example invokes ATAN2:

SELECT {fn ATAN2(15,30)} AS ArcTangent 

returns 0.46

See Also

FeedbackOpens in a new tab