Skip to main content

Trigonometric Functions

HelixQL provides a comprehensive set of trigonometric functions for angular calculations, including standard trigonometric functions (sine, cosine, tangent) and their inverse counterparts, essential for geospatial calculations, physics simulations, and angular measurements.

Available Functions

SIN - Sine

Returns the sine of an angle in radians.

COS - Cosine

Returns the cosine of an angle in radians.

TAN - Tangent

Returns the tangent of an angle in radians.

ASIN - Arcsine

Returns the arcsine (inverse sine) of x in radians. Domain: [-1, 1].

ACOS - Arccosine

Returns the arccosine (inverse cosine) of x in radians. Domain: [-1, 1].

ATAN - Arctangent

Returns the arctangent (inverse tangent) of x in radians.

ATAN2 - Two-Argument Arctangent

Returns the angle in radians between the positive x-axis and the point (x, y). This function handles all quadrants correctly and is commonly used for angle calculations.
When using the SDKs or curling the endpoint, the query name must match what is defined in the queries.hx file exactly.

Example 1: Geospatial bearing calculations

Calculate the bearing (direction) between geographic coordinates:
Here’s how to run the query using the SDKs or curl

Example 2: Angle calculations with ATAN2

Use ATAN2 to calculate angles between vectors and points:
Here’s how to run the query using the SDKs or curl

Example 3: Inverse trigonometric functions

Use inverse trigonometric functions to recover angles from ratios:
Here’s how to run the query using the SDKs or curl

Radians vs Degrees

All trigonometric functions in HelixQL work with radians. To convert between degrees and radians:
Use the PI() constant function for accurate conversion between degrees and radians.

Domain Restrictions

Inverse trigonometric functions have domain restrictions:
  • ASIN(x), ACOS(x): x must be in [-1, 1]
  • ATAN(x): accepts all real numbers
  • ATAN2(y, x): accepts all real numbers for both arguments

ATAN2 vs ATAN

ATAN2 is preferred over ATAN for angle calculations because:
  • It handles all four quadrants correctly
  • It avoids division by zero when x = 0
  • It returns values in the full range [-π, π]

Use in Geospatial Calculations

Trigonometric functions are essential for geospatial calculations:

Unary Math Functions

SQRT, ABS, LN, LOG10, EXP, CEIL, FLOOR, ROUND

Constants

PI and E constants

Arithmetic Functions

ADD, SUB, MUL, DIV, POW, MOD

Math Overview

Overview of all math functions