Trigonometric functions
This page describes the available functions to assist with performing trigonometric calculations.
tip
Positive and negative infinity values are expressed as 'Infinity'
or
'-Infinity'
in QuestDB.
#
sinsin(angleRadians)
returns the trigonometric sine of an angle.
#
ArgumentsangleRadians
is a numeric value indicating the angle in radians.
#
Return valueReturn value type is double
.
#
DescriptionSpecial case: if the argument is NaN
or an infinity, then the result is Null
.
#
Examplesangle | sin |
---|---|
1.570796326794 | 1 |
#
coscos(angleRadians)
returns the trigonometric cosine of an angle.
#
ArgumentsangleRadians
numeric value for the angle, in radians.
#
Return valueReturn value type is double
.
#
DescriptionSpecial case: if the argument is NaN
or an infinity, then the result is Null
.
#
Examplesangle | cos |
---|---|
1.570796326794 | 6.123233995736766e-17 |
#
tantan(angleRadians)
returns the trigonometric tangent of an angle.
#
ArgumentsangleRadians
numeric value for the angle, in radians.
#
Return valueReturn value type is double
.
#
DescriptionSpecial case: if the argument is NaN
or an infinity, then the result is Null
.
#
Examplesangle | tan |
---|---|
1.570796326794 | 16331239353195370 |
#
cotcot(angleRadians)
returns the trigonometric cotangent of an angle.
#
ArgumentsangleRadians
numeric value for the angle, in radians.
#
Return valueReturn value type is double
.
#
DescriptionSpecial case: if the argument is NaN
, 0, or an infinity, then the result is Null
.
#
Examplesangle | cot |
---|---|
1.570796326794 | 6.123233995736766e-17 |
#
asinasin(value)
the arcsine of a value.
#
Argumentsvalue
is a numeric value whose arcsine is to be returned.
#
Return valueReturn value type is double
. The returned angle is between -pi/2 and pi/2
inclusively.
#
DescriptionSpecial case: if the argument is NaN
or an infinity, then the result is Null
.
#
Examplesasin |
---|
1.570796326794 |
#
acosacos(value)
returns the arccosine of a value.
#
Argumentsvalue
is a numeric value whose arccosine is to be returned. The returned angle is between 0.0 and pi inclusively.
#
Return valueReturn value type is double
.
#
DescriptionSpecial cases: if the argument is NaN
or its absolute value is greater than 1, then the
result is Null
.
#
Examplesacos |
---|
1.570796326794 |
#
atanatan(value)
returns the arctangent of a value.
#
Argumentsvalue
is a numeric value whose arctangent is to be returned.
#
Return valueReturn value type is double
. The returned angle is between -pi/2 and pi/2
inclusively.
#
DescriptionSpecial cases:
- If the argument is
NaN
, then the result isNull
. - If the argument is infinity, then the result is the closest value to pi/2 with the same sign as the input.
#
ExamplesSpecial case where input is '-Infinity'
:
Returns the closest value to pi/2 with the same sign as the input:
atan |
---|
-1.570796326794 |
atan |
---|
0.785398163397 |
#
atan2atan2(valueY, valueX)
returns the angle theta from the conversion of
rectangular coordinates (x, y) to polar (r, theta). This function computes
theta (the phase) by computing an arctangent of y/x in the range of -pi to pi
inclusively.
#
ArgumentsvalueY
numeric ordinate coordinate.valueX
numeric abscissa coordinate.
note
The arguments to this function pass the y-coordinate first and the x-coordinate second.
#
Return valueReturn value type is double
between -pi and pi inclusively.
#
Description:atan2(valueY, valueX)
measures the counterclockwise angle theta, in radians,
between the positive x-axis and the point (x, y):
Special cases:
input valueY | input valueX | atan2 return value |
---|---|---|
0 | Positive value | 0 |
Positive finite value | 'Infinity' | 0 |
-0 | Positive value | 0 |
Negative finite value | 'Infinity' | 0 |
0 | Negative value | Double value closest to pi |
Positive finite value | '-Infinity' | Double value closest to pi |
-0 | Negative value | Double value closest to -pi |
Negative finite value | '-Infinity' | Double value closest to -pi |
Positive value | 0 or -0 | Double value closest to pi/2 |
'Infinity' | Finite value | Double value closest to pi/2 |
Negative value | 0 or -0 | Double value closest to -pi/2 |
'-Infinity' | Finite value | Double value closest to -pi/2 |
'Infinity' | 'Infinity' | Double value closest to pi/4 |
'Infinity' | '-Infinity' | Double value closest to 3/4 * pi |
'-Infinity' | 'Infinity' | Double value closest to -pi/4 |
'-Infinity' | '-Infinity' | Double value closest to -3/4 * pi |
#
Examplesatan2 |
---|
0.785398163397 |
#
radiansradians(angleDegrees)
converts an angle measured in degrees to the equivalent
angle measured in radians.
#
ArgumentsangleDegrees
numeric value for the angle in degrees.
#
Return valueReturn value type is double
.
#
Examplesradians |
---|
3.141592653589 |
#
degreesdegrees(angleRadians)
converts an angle measured in radians to the equivalent
angle measured in degrees.
#
ArgumentsangleRadians
numeric value for the angle in radians.
#
Return valueReturn value type is double
.
#
Examplesdegrees |
---|
180 |
#
pipi()
returns the constant pi as a double.
#
ArgumentsNone.
#
Return valueReturn value type is double
.
#
Examplespi |
---|
3.141592653589 |