All Products
Search
Document Center

PolarDB:Trigonometric functions

Last Updated:Jan 23, 2025

This topic describes the trigonometric functions of AGE.

degrees

degrees() converts radians to degrees.

Syntax

degrees(expression)

Return value

An agtype floating-point number.

Parameters

Parameter

Description

expression

An agtype number expression that represents the angle in radians.

Usage notes

degrees(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN degrees(3.14159)
$$) as (deg agtype);

The number of degrees close to π is returned.

       deg        
------------------
 179.999847960504
(1 row)

radians

radians() converts degrees to radians.

Syntax

radians(expression)

Return value

An agtype floating-point number.

Parameters

Parameter

Description

expression

An agtype number expression that represents the angle in degrees.

Usage notes

radians(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN radians(180)
$$) as (rad agtype);

The radian value close to π is returned.

       rad        
------------------
 3.14159265358979
(1 row)

pi

pi() returns the mathematical constant π.

Syntax

pi()

Return value

An agtype floating-point number.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN pi()
$$) as (p agtype);

The constant π is returned.

        p         
------------------
 3.14159265358979
(1 row)

sin

sin() returns the sine of a number.

Syntax

sin(expression)

Return value

An agtype floating-point number.

Parameters

Parameter

Description

expression

An agtype number expression that represents the angle in radians.

Usage notes

sin(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN sin(0.5)
$$) as (s agtype);

The sine of 0.5 is returned.

         s         
-------------------
 0.479425538604203
(1 row)

cos

cos() returns the cosine of a number.

Syntax

cos(expression)

Return value

An agtype floating-point number.

Parameters

Parameter

Description

expression

An agtype number expression that represents the angle in radians.

Usage notes

cos(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN cos(0.5)
$$) as (c agtype);

The cosine of 0.5 is returned.

         c         
-------------------
 0.877582561890373
(1 row)

tan

tan() returns the tangent of a number.

Syntax

tan(expression)

Return value

An agtype floating-point number.

Parameters

Parameter

Description

expression

An agtype number expression that represents the angle in radians.

Usage notes

tan(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN tan(0.5)
$$) as (t agtype);

The tangent of 0.5 is returned.

        t         
------------------
 0.54630248984379
(1 row)

cot

cot() returns the cotangent of a number.

Syntax

cot(expression)

Return value

An agtype floating-point number.

Parameters

Parameter

Description

expression

An agtype number expression that represents the angle in radians.

Usage notes

cot(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN cot(0.5)
$$) as (t agtype);

The cotangent of 0.5 is returned.

        t         
------------------
 1.83048772171245
(1 row)

asin

asin() returns the arcsine of a number.

Syntax

asin(expression)

Return value

An agtype floating-point number.

Parameters

Parameter

Description

expression

An agtype number expression that represents the angle in radians.

Usage notes

  • asin(null) returns null.

  • If expression < -1 or expression > 1, asin(expression) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN asin(0.5)
$$) as (arc_s agtype);

The arcsine of 0.5 is returned.

       arc_s       
-------------------
 0.523598775598299
(1 row)

acos

acos() returns the arccosine of a number.

Syntax

acos(expression)

Return value

An agtype floating-point number.

Parameters

Parameter

Description

expression

An agtype number expression that represents the angle in radians.

Usage notes

  • acos(null) returns null.

  • If expression < -1 or expression > 1, acos(expression) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN acos(0.5)
$$) as (arc_c agtype);

The arccosine of 0.5 is returned.

      arc_c      
-----------------
 1.0471975511966
(1 row)

atan

atan() returns the arctangent of a number.

Syntax

atan(expression)

Return value

An agtype floating-point number.

Parameters

Parameter

Description

expression

An agtype number expression that represents the angle in radians.

Usage notes

atan(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN atan(0.5)
$$) as (arc_t agtype);

The arctangent of 0.5 is returned.

       arc_t       
-------------------
 0.463647609000806
(1 row)

atan2

atan2() returns the arctangent of a set of coordinates in radians.

Syntax

atan2(expression1, expression2)

Return value

An agtype floating-point number.

Parameters

Parameter

Description

expression1

An agtype number expression for y that represents the angle in radians.

expression2

An agtype number expression for x that represents the angle in radians.

Usage notes

atan2(null, null), atan2(null, expression2) and atan(expression1, null) return null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN atan2(0.5, 0.6)
$$) as (arc_t2 agtype);

The arctangent of 0.5 and 0.6 is returned.

      arc_t2       
-------------------
 0.694738276196703
(1 row)