PostgreSQL/Math Functions/atan2
atan, atan2(-1, 0), atan
postgres=# SELECT atan2(1, 0) AS positive_x,
postgres-# atan2(-1, 0) AS negative_x,
postgres-# atan2(0, 0) AS zero_x,
postgres-# pi() / 2 AS pi_over_two;
positive_x | negative_x | zero_x | pi_over_two
-----------------+------------------+--------+-----------------
1.5707963267949 | -1.5707963267949 | 0 | 1.5707963267949
(1 row)
postgres=#
atan2(x, y): Returns the inverse tangent of the quotient of x and y
postgres=#
postgres=# -- atan2(x, y): Returns the inverse tangent of the quotient of x and y
postgres=# SELECT atan2(0, 1), atan2(1, 1),
postgres-# atan(0 / 1) AS functionally,
postgres-# atan(1 / 1) AS identical;
atan2 | atan2 | functionally | identical
-------+-------------------+--------------+-------------------
0 | 0.785398163397448 | 0 | 0.785398163397448
(1 row)
postgres=#