Mathematical functions - trigonometric
Trigonometric mathematical functions operate on numeric expressions only, and will return an error if used on any other values. See also Mathematical operators.
acos()
acos()
returns the arccosine of a FLOAT
in radians.
Syntax:
acos(expression)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A numeric expression that represents the angle in radians. |
Considerations:
|
If ( |
RETURN acos(0.5)
The arccosine of 0.5
is returned.
acos(0.5) |
---|
|
Rows: 1 |
asin()
asin()
returns the arcsine of a FLOAT
in radians.
Syntax:
asin(expression)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A numeric expression that represents the angle in radians. |
Considerations:
|
If ( |
RETURN asin(0.5)
The arcsine of 0.5
is returned.
asin(0.5) |
---|
|
Rows: 1 |
atan()
atan()
returns the arctangent of a FLOAT
in radians.
Syntax:
atan(expression)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A numeric expression that represents the angle in radians. |
Considerations:
|
RETURN atan(0.5)
The arctangent of 0.5
is returned.
atan(0.5) |
---|
|
Rows: 1 |
atan2()
atan2()
returns the arctangent2 of a set of coordinates in radians.
Syntax:
atan2(expression1, expression2)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A numeric expression for y that represents the angle in radians. |
|
A numeric expression for x that represents the angle in radians. |
Considerations:
|
RETURN atan2(0.5, 0.6)
The arctangent2 of 0.5
and 0.6
is returned.
atan2(0.5, 0.6) |
---|
|
Rows: 1 |
cos()
cos()
returns the cosine of a FLOAT
.
Syntax:
cos(expression)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A numeric expression that represents the angle in radians. |
Considerations:
|
RETURN cos(0.5)
The cosine of 0.5
is returned.
cos(0.5) |
---|
|
Rows: 1 |
cot()
cot()
returns the cotangent of a FLOAT
.
Syntax:
cot(expression)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A numeric expression that represents the angle in radians. |
Considerations:
|
|
RETURN cot(0.5)
The cotangent of 0.5
is returned.
cot(0.5) |
---|
|
Rows: 1 |
degrees()
degrees()
converts radians to degrees.
Syntax:
degrees(expression)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A numeric expression that represents the angle in radians. |
Considerations:
|
RETURN degrees(3.14159)
The number of degrees in something close to pi is returned.
degrees(3.14159) |
---|
|
Rows: 1 |
haversin()
haversin()
returns half the versine of a number.
Syntax:
haversin(expression)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A numeric expression that represents the angle in radians. |
Considerations:
|
RETURN haversin(0.5)
The haversine of 0.5
is returned.
haversin(0.5) |
---|
|
Rows: 1 |
Spherical distance using the haversin()
function
The haversin()
function may be used to compute the distance on the surface of a sphere between two points (each given by their latitude and longitude).
In this example the spherical distance (in km) between Berlin in Germany (at lat 52.5, lon 13.4) and San Mateo in California (at lat 37.5, lon -122.3) is calculated using an average earth radius of 6371 km.
CREATE (ber:City {lat: 52.5, lon: 13.4}), (sm:City {lat: 37.5, lon: -122.3})
RETURN 2 * 6371 * asin(sqrt(haversin(radians( sm.lat - ber.lat ))
+ cos(radians( sm.lat )) * cos(radians( ber.lat )) *
haversin(radians( sm.lon - ber.lon )))) AS dist
The estimated distance between 'Berlin' and 'San Mateo' is returned.
dist |
---|
|
Rows: 1 |
pi()
pi()
returns the mathematical constant pi.
Syntax:
pi()
Returns:
|
RETURN pi()
The constant pi is returned.
pi() |
---|
|
Rows: 1 |
radians()
radians()
converts degrees to radians.
Syntax:
radians(expression)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A numeric expression that represents the angle in degrees. |
Considerations:
|
RETURN radians(180)
The number of radians in 180
degrees is returned (pi).
radians(180) |
---|
|
Rows: 1 |
sin()
sin()
returns the sine of a number.
Syntax:
sin(expression)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A numeric expression that represents the angle in radians. |
Considerations:
|
RETURN sin(0.5)
The sine of 0.5
is returned.
sin(0.5) |
---|
|
Rows: 1 |
tan()
tan()
returns the tangent of a number.
Syntax:
tan(expression)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A numeric expression that represents the angle in radians. |
Considerations:
|
RETURN tan(0.5)
The tangent of 0.5
is returned.
tan(0.5) |
---|
|
Rows: 1 |
Was this page helpful?