Engine.Math

The Math library provides several functions to do mathematical operations or calculations. Most of these functions are simply aliases of the functions built into JavaScript.

Table of contents

Engine.Math.Absolute(x)
Engine.Math.Abs(x)
Returns the absolute value of x.
This is an alias of the standard Math.abs function in JavaScript.
x
The number.
Example: Get the absolute value of a positive number
Code:
Engine.Math.Absolute(16);
Output:
16
Example: Get the absolute value of a negative number
Code:
Engine.Math.Absolute(-23);
Output:
23
Engine.Random.Sum(item [, item [, item ...]])
Engine.Random.Sum(itemarray)
Returns the sum of all supplied numbers.
item
An individual number. itemarray:: An array of numbers.
Example: Sum several numbers using individual arguments
Code:
Engine.Math.Sum(42, 6, 17, 2, 7);
Output:
74
Example: Sum several numbers using an array
Code:
var numbers = [42, 6, 17, 2, 7];
Engine.Math.Sum(numbers);
Output:
74
Engine.Math.Round(x)
Rounds x to the nearest integer.
This is an alias of the standard Math.round function in JavaScript.
x
The value to round.
Example: Rounding a number in the upper half
Code:
Engine.Math.Ceiling(82.62);
Output:
83
Example: Rounding a number in the lower half
Code:
Engine.Math.Ceiling(82.13);
Output:
82
Engine.Math.Ceiling(x)
Engine.Math.Ceil(x)
Rounds up x.
This is an alias of the standard Math.ceil function in JavaScript.
x
The value to round up.
Example: Rounding up a number
Code:
Engine.Math.Ceiling(614.2162);
Output:
615
Engine.Math.Floor(x)
Rounds down x.
This is an alias of the standard Math.floor function in JavaScript.
x
The value to round down.
Example: Rounding down a number
Code:
Engine.Math.Floor(7.612);
Output:
7
Engine.Math.Tangent(x)
Engine.Math.Tan(x)
Returns the tangent of angle x.
This is an alias of the standard Math.tan function in JavaScript.
x
The value.
Example: Calculating the tangent
Code:
Engine.Math.Tangent(84.15);
Output:
-0.7971515163204654
Engine.Math.Cosine(x)
Engine.Math.Cos(x)
Returns the cosine of x.
This is an alias of the standard Math.cos function in JavaScript.
x
The value (in radians).
Example: Calculating the cosine
Code:
Engine.Math.Cosine(162.54);
Output:
0.6801581420388815
Engine.Math.Sine(x)
Engine.Math.Sin(x)
Returns the sine of x.
This is an alias of the standard Math.sin function in JavaScript.
x
The value (in radians).
Example: Calculating the sine
Code:
Engine.Math.Sine(62.4);
Output:
-0.41855446451842543