System Math API

System Math API is a set of mathematical methods and properties ready to use in Expression language (AEL) and JavaScript.

๐Ÿ‘

Javascript

All Automate APIs, including System Math API, can be used in JavaScript expressions and functions.

System Math APIDescription
system.math.zeroReturns 0.
system.math.PIReturns PI.
system.math.sqrt(n)Returns square root of a given number.
system.math.pow(a, b)Returns a to the power of b.
system.math.sin(x)Returns sinus of x (in radians).
system.math.cos(x)Returns cosinus of x (in radians).
system.math.distance(x1, y1, x2, y2)Returns Euclidean plane distance between two points.
system.math.geoDistance(lat1, lon1, lat2, lon2)Returns distance between two points.

system.math.zero

Returns 0.

system.math.zero

// Result:
0

system.math.PI

Returns PI number (3.14...)

system.math.PI 

// Result:
3.141592653589793

system.math.sqrt(n)

Returns square root of a Number provided as an argument (n).

If a provided Number isn't a perfect square, the result will be rounded out.

system.math.sqrt(16) 

// Result:
4

system.math.pow(a, b)

Returns a to the power of b.

system.math.pow(4,2) 

// Result:
16

system.math.sin(x)

Returns sinus of x (in radians).

system.math.sin(x)

// Result: 
0.8414709848078965

system.math.cos(x)

Returns cosinus of x (in radians)

system.math.cos(1)

// Result:
0.5403023058681398

system.math.distance(x1, y1, x2, y2)

Returns Euclidean plane distance (calculated from Pythagoras theorem) from point A(x1, y2) to B(x2, y2).

This method is faster to calculate distance than system.math.geoDistance().

For Polish, it needs touse 2*x, where x is a longitude.

system.math.distance(3,2,1,0) 

// Result:
2.8284271247461903

system.math.geoDistance(lat1, lon1, lat2, lon2)

Returns distance in kilometers based on two coordinates: latitude and longtitude.

For W|S coordinates, use negatives.

system.math.geoDistance(54.49458142405042, 18.488531909098697,54.49667501758221, 18.499089084025645)

// Result:
0.7204128609625717

Whatโ€™s Next

Learn more about Expression language and its methods & APIs: