API Reference
Classes
Math
Utility class for mathematical operations.
Static Functions
Name | Description |
---|---|
abs | Returns the absolute value of a number. |
acos | Returns the inverse cosine (in radians) of a number. |
acot | Calculates the inverse cotangent (acot) of a number. |
acsc | Calculates the inverse cosecant (acsc) of a number. |
arithmeticMean | Calculates the mean value of an array of numbers. |
asec | Calculates the inverse secant (asec) of a number. |
asin | Returns the inverse sine (in radians) of a number. |
atan | Returns the inverse tangent (in radians) of a number. |
atan2 | Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y), for Math.atan2(y, x). |
ceil | Returns the smallest integer greater than or equal to a given number. |
combinations | Calculates the number of combinations for choosing r items from a total of n items. |
cos | Returns the cosine of a number in radians. |
cot | Calculates the cotangent of an angle (in radians). |
csc | Calculates the cosecant of an angle (in radians). |
degreesToRadians | Convert degrees to radians. |
factorial | Calculates the factorial of a given number. |
fibonacci | Calculates the nth Fibonacci number. |
floor | Returns the largest integer less than or equal to a given number. |
geometricMean | Calculates the geometric mean of an array of numbers. |
harmonicMean | Calculates the harmonic mean of an array of numbers. |
hypot | Calculate the length of the vector from the origin to the point given by the coordinates. |
isPrime | Checks if a number is prime. |
max | Returns the maximum value from an array of numbers. |
median | Calculates the median value of an array of numbers. |
min | Returns the minimum value from an array of numbers. |
mode | Calculates the mode values of an array of numbers. |
radiansToDegrees | Convert radians to degrees. |
random | Generates a pseudo-random number between 0 and max (default of 1). |
round | Rounds the given number to the nearest integer. |
sec | Calculates the secant of an angle (in radians). |
sin | Returns the sine of a number in radians. |
sqrt | Returns the square root of a number. |
tan | Returns the tangent of a number in radians. |
abs
bring math;
math.abs(value: num);
Returns the absolute value of a number.
value
Required
- Type: num
The input number.
acos
bring math;
math.acos(value: num);
Returns the inverse cosine (in radians) of a number.
value
Required
- Type: num
A number between -1 and 1, inclusive, representing the angle's cosine value.
acot
bring math;
math.acot(value: num);
Calculates the inverse cotangent (acot) of a number.
value
Required
- Type: num
A number representing the cotangent value.
acsc
bring math;
math.acsc(value: num);
Calculates the inverse cosecant (acsc) of a number.
value
Required
- Type: num
A number equal or greater than |1|, representing the cosecant value.
arithmeticMean
bring math;
math.arithmeticMean(arr: MutArray<num>);
Calculates the mean value of an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
asec
bring math;
math.asec(value: num);
Calculates the inverse secant (asec) of a number.
value
Required
- Type: num
A number equal or greater than |1|, representing the secant value.
asin
bring math;
math.asin(value: num);
Returns the inverse sine (in radians) of a number.
value
Required
- Type: num
A number between -1 and 1, inclusive, representing the angle's sine value.
atan
bring math;
math.atan(value: num);
Returns the inverse tangent (in radians) of a number.
value
Required
- Type: num
A number.
atan2
bring math;
math.atan2(y: num, x: num);
Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y), for Math.atan2(y, x).
y
Required
- Type: num
The y coordinate of the point.
x
Required
- Type: num
The x coordinate of the point.
ceil
bring math;
math.ceil(value: num);
Returns the smallest integer greater than or equal to a given number.
value
Required
- Type: num
The input number.
combinations
bring math;
math.combinations(n: num, r: num);
Calculates the number of combinations for choosing r items from a total of n items.
n
Required
- Type: num
The total number of items.
r
Required
- Type: num
The number of items to be chosen.
cos
bring math;
math.cos(value: num);
Returns the cosine of a number in radians.
value
Required
- Type: num
A number representing an angle in radians.
cot
bring math;
math.cot(value: num);
Calculates the cotangent of an angle (in radians).
value
Required
- Type: num
The angle in radians.
csc
bring math;
math.csc(value: num);
Calculates the cosecant of an angle (in radians).
value
Required
- Type: num
The angle in radians.
degreesToRadians
bring math;
math.degreesToRadians(degrees: num);
Convert degrees to radians.
degrees
Required
- Type: num
Degree value.
factorial
bring math;
math.factorial(n: num);
Calculates the factorial of a given number.
n
Required
- Type: num
The number to calculate the factorial for.
fibonacci
bring math;
math.fibonacci(n: num);
Calculates the nth Fibonacci number.
n
Required
- Type: num
The position of the Fibonacci number to calculate.
floor
bring math;
math.floor(value: num);
Returns the largest integer less than or equal to a given number.
value
Required
- Type: num
The input number.
geometricMean
bring math;
math.geometricMean(arr: MutArray<num>);
Calculates the geometric mean of an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
harmonicMean
bring math;
math.harmonicMean(arr: MutArray<num>);
Calculates the harmonic mean of an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
hypot
bring math;
math.hypot(coordinates: MutArray<num>);
Calculate the length of the vector from the origin to the point given by the coordinates.
coordinates
Required
- Type: MutArray<num>
Array of coordinates.
isPrime
bring math;
math.isPrime(n: num);
Checks if a number is prime.
n
Required
- Type: num
The number to check for primality.
max
bring math;
math.max(arr: MutArray<num>);
Returns the maximum value from an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
median
bring math;
math.median(arr: MutArray<num>);
Calculates the median value of an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
min
bring math;
math.min(arr: MutArray<num>);
Returns the minimum value from an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
mode
bring math;
math.mode(arr: MutArray<num>);
Calculates the mode values of an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
radiansToDegrees
bring math;
math.radiansToDegrees(radians: num);
Convert radians to degrees.
radians
Required
- Type: num
Radians value.
random
bring math;
math.random(max?: num);
Generates a pseudo-random number between 0 and max (default of 1).
max
Optional
- Type: num
The maximum value of the random number.
round
bring math;
math.round(value: num, options?: RoundingOptions);
Rounds the given number to the nearest integer.
value
Required
- Type: num
The number to be rounded.
options
Optional
- Type: RoundingOptions
sec
bring math;
math.sec(value: num);
Calculates the secant of an angle (in radians).
value
Required
- Type: num
The angle in radians.
sin
bring math;
math.sin(value: num);
Returns the sine of a number in radians.
value
Required
- Type: num
A number representing an angle in radians.
sqrt
bring math;
math.sqrt(value: num);
Returns the square root of a number.
value
Required
- Type: num
A number greater than or equal to 0.
tan
bring math;
math.tan(value: num);
Returns the tangent of a number in radians.
value
Required
- Type: num
A number representing an angle in radians.
Constants
Name | Type | Description |
---|---|---|
E | num | Euler's number, a mathematical constant approximately equal to 2.71828. |
INF | num | Positive infinity constant. |
PI | num | The mathematical constant representing the ratio of a circle's circumference to its diameter. |
TAU | num | The mathematical constant representing the ratio of a circle's circumference to the radius. |
E
Required
E: num;
- Type: num
Euler's number, a mathematical constant approximately equal to 2.71828.
INF
Required
INF: num;
- Type: num
Positive infinity constant.
PI
Required
PI: num;
- Type: num
The mathematical constant representing the ratio of a circle's circumference to its diameter.
TAU
Required
TAU: num;
- Type: num
The mathematical constant representing the ratio of a circle's circumference to the radius.
Structs
RoundingOptions
Options for rounding a number.
Initializer
bring math;
let RoundingOptions = math.RoundingOptions{ ... };
Properties
Name | Type | Description |
---|---|---|
decimalPlaces | num | The number of decimal places to round to. |
decimalPlaces
Optional
decimalPlaces: num;
- Type: num
The number of decimal places to round to.