You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
2.6 KiB
Plaintext
151 lines
2.6 KiB
Plaintext
# 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.
|
|
|
|
{TOC}
|
|
|
|
^ 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.
|
|
|
|
@ Get the absolute value of a positive number
|
|
|
|
$ Engine.Math.Absolute(16);
|
|
|
|
> 16
|
|
|
|
@ Get the absolute value of a negative number
|
|
|
|
$ Engine.Math.Absolute(-23);
|
|
|
|
> 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.
|
|
|
|
@ Sum several numbers using individual arguments
|
|
|
|
$ Engine.Math.Sum(42, 6, 17, 2, 7);
|
|
|
|
> 74
|
|
|
|
@ Sum several numbers using an array
|
|
|
|
$ var numbers = [42, 6, 17, 2, 7];
|
|
Engine.Math.Sum(numbers);
|
|
|
|
> 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.
|
|
|
|
@ Rounding a number in the upper half
|
|
|
|
$ Engine.Math.Ceiling(82.62);
|
|
|
|
> 83
|
|
|
|
@ Rounding a number in the lower half
|
|
|
|
$ Engine.Math.Ceiling(82.13);
|
|
|
|
> 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.
|
|
|
|
@ Rounding up a number
|
|
|
|
$ Engine.Math.Ceiling(614.2162);
|
|
|
|
> 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.
|
|
|
|
@ Rounding down a number
|
|
|
|
$ Engine.Math.Floor(7.612);
|
|
|
|
> 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.
|
|
|
|
@ Calculating the tangent
|
|
|
|
$ Engine.Math.Tangent(84.15);
|
|
|
|
> -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).
|
|
|
|
@ Calculating the cosine
|
|
|
|
$ Engine.Math.Cosine(162.54);
|
|
|
|
> 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).
|
|
|
|
@ Calculating the sine
|
|
|
|
$ Engine.Math.Sine(62.4);
|
|
|
|
> -0.41855446451842543
|