The _math operator can be used to run javascript Math methods.
The _math operator can take arguments in the following forms:
No Arguments
(void): numberSome methods like _math.PI take no arguments:
_math.PI: nullReturns: pi
Single argument
(x: number): numberSome methods like _math.round take a single argument:
_math.round: 3.14Returns: 3
Named arguments
({x: number, y: number}): number
([x: number, y: number]): number
Some methods like _math.pow take an object with named arguments:
_math.pow:
base: 2
exponent: 3Returns: 8
These methods also accept their arguments as an array:
_math.pow:
- 2
- 3Returns: 8
Array arguments
(values: number[]): numberSome methods like _math.max take an array of values as arguments:
_math.max:
- 42
- 99
- 0Returns: 99
Operator methods:
_math.abs
(x: number): numberThe _math.abs method returns the absolute value of a number.
_math.acos
(x: number): numberThe _math.acos method returns the arccosine (in radians) of a number.
_math.acosh
(x: number): numberThe _math.acosh method returns the hyperbolic arc-cosine of a number.
_math.asin
(x: number): numberThe _math.asin method returns the arcsine (in radians) of a number.
_math.atan
(x: number): numberThe _math.atan method returns the arctangent (in radians) of a number.
_math.atan2
({x: number, y: number}): number
([x: number, y: number]): numberThe _math.atan2 method returns the angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x,y).
_math.atanh
(x: number): numberThe _math.atanh method returns the hyperbolic arctangent of a number.
_math.cbrt
(x: number): numberThe _math.cbrt method returns the returns the cube root of a number.
_math.ceil
(x: number): numberThe _math.ceil method rounds a number up to the next largest integer.
_math.clz32
(x: number): numberThe _math.clz32 method returns the number of leading zero bits in the 32-bit binary representation of a number.
_math.cos
(x: number): numberThe _math.cos method returns the cosine of the specified angle, which must be specified in radians
_math.cosh
(x: number): numberThe _math.cosh method returns the hyperbolic cosine of a number.
_math.exp
(x: number): numberThe _math.exp method returns e (Euler's number) to the power x.
_math.expm1
(x: number): numberThe _math.expm1 method returns e (Euler's number) to the power x minus 1.
_math.floor
(x: number): numberThe _math.floor method returns the largest integer less than or equal to a given number.
_math.fround
(x: number): numberThe _math.fround method returns the nearest 32-bit single precision float representation of a number.
_math.hypot
(values: number[]): numberThe _math.hypot method returns the square root of the sum of squares of its arguments.
_math.imul
({a: number, b: number}): number
([a: number, b: number]): numberThe _math.imul method returns the result of the C-like 32-bit multiplication of the two parameters.
_math.log
(x: number): numberThe _math.log method returns the natural logarithm (base e) of a number.
_math.log10
(x: number): numberThe _math.log10 method returns the base 10 logarithm of a number.
_math.log1p
(x: number): numberThe _math.log1p method returns the natural logarithm (base e) of 1 + a number.
_math.log2
(x: number): numberThe _math.log2 method returns the base 2 logarithm of a number.
_math.max
(values: number[]): numberThe _math.max method returns the largest of the numbers given as input parameters.
_math.min
(values: number[]): numberThe _math.min method returns the smallest of the numbers given as input parameters.
_math.pow
({base: number, exponent: number}): number
([base: number, exponent: number]): numberThe _math.pow method returns the base to the exponent power.
_math.random
(void): numberThe _math.random method returns a floating-point, pseudo-random number in the range 0 to less than 1.
_math.round
(x: number): numberThe _math.round method returns the value of a number rounded to the nearest integer.
_math.sign
(x: number): numberThe _math.sign method returns either a positive or negative 1 (+/- 1), indicating the sign of a number passed into the argument.
_math.sin
(x: number): numberThe _math.sin method returns the sine of a number.
_math.sinh
(x: number): numberThe _math.sinh method returns the hyperbolic sine of a number.
_math.sqrt
(x: number): numberThe _math.sqrt method returns the square root of a number.
_math.tan
(x: number): numberThe _math.tan method returns the tangent of a number.
_math.trunc
(x: number): numberThe _math.trunc method returns the integer part of a number by removing any fractional digits.
_math.E
(void): numberThe _math.E method returns Euler's number, the base of natural logarithms, e, which is approximately 2.718.
_math.LN10
(void): numberThe _math.LN10 method returns the natural logarithm of 10, which is approximately 2.302.
_math.LN2
(void): numberThe _math.LN2 method returns the natural logarithm of 2, which is approximately 0.693.
_math.LOG10E
(void): numberThe _math.LOG10E method returns the base 10 logarithm of e, which is approximately 0.434.
_math.LOG2E
(void): numberThe _math.LOG2E method returns the base 2 logarithm of e, which is approximately 1.442.
_math.PI
(void): numberThe _math.PI method returns the constant pi, the ratio of the circumference of a circle to its diameter, which is approximately 3.14159.
_math.SQRT1_2
(void): numberThe _math.SQRT1_2 method returns the square root of 1/2, which is approximately 0.707.
_math.SQRT2
(void): numberThe _math.SQRT2 method returns the square root of 2, which is approximately 1.414.
