PostgreSQL atan2d() Function
The PostgreSQL atan2d()
function returns the arc tangent of the result of the division of two specified numbers, in degrees.
atan2d()
Syntax
This is the syntax of the PostgreSQL atan2d()
function:
atan2d(x, y)
Parameters
x
-
Required. The dividend.
y
-
Required. The divisor.
Return value
The PostgreSQL atan2d(x, y)
function returns the arc tangent of the result of the division of two specified numbers, in degrees.
If the parameter number
is NULL
, the atan2d()
function will return NULL
.
atan2d()
Examples
Here are a few examples of the atan2d()
function:
SELECT
atan2d(1, 0) AS "atan2d(1, 0)",
atan2d(1, 2) AS "atan2d(1, 2)",
atan2d(0, 1) AS "atan2d(0, 1)";
-[ RECORD 1 ]+-------------------
atan2d(1, 0) | 90
atan2d(1, 2) | 26.565051177077986
atan2d(0, 1) | 0
atan2d(x, y)
is equivalent to atand(x / y)
, for example:
SELECT
atan2d(1, 2) AS "atan2d(1, 2)",
atand(0.5) AS "atand(0.5)";
-[ RECORD 1 ]+-------------------
atan2d(1, 2) | 26.565051177077986
atand(0.5) | 26.565051177077986
Here, we found that atan2d(1, 2)
and atand(0.5)
returned the same result.
atan2d(x, y)
is equivalent to calculating atan2(x, y)
first and then converting the result to degrees using degrees()
, for example:
SELECT
atan2d(1, 0) AS "atan2d(1, 0)",
degrees(atan2(1, 0)) AS "degrees(atan2(1, 0))";
-[ RECORD 1 ]--------+---
atan2d(1, 0) | 90
degrees(atan2(1, 0)) | 90