new Math()
Math utility.
- Source:
Methods
-
<static> distance(x0, y0, x1, y1) → {number}
-
Euclidean distance between two points P(x0, y0) and P(x1, y1).
Parameters:
Name Type Description x0number Horizontal coordinate of P0. y0number Vertical coordinate of P0. x1number Horizontal coordinate of P1. y1number Vertical coordinate of P1. - Source:
Returns:
The euclidean distance.- Type
- number
-
<static> hammingWeight(i) → {number}
-
Calculates the Hamming weight of a string, which is the number of symbols that are different from the zero-symbol of the alphabet used. It is thus equivalent to the Hamming distance from the all-zero string of the same length. For the most typical case, a string of bits, this is the number of 1's in the string. Example:
Binary string Hamming weight 11101 4 11101010 5
Parameters:
Name Type Description inumber Number that holds the binary string to extract the hamming weight. - Source:
Returns:
The hamming weight.- Type
- number
-
<static> intersectRect(x0, y0, x1, y1, x2, y2, x3, y3) → {boolean}
-
Tests if a rectangle intersects with another.
x0y0 -------- x2y2 -------- | | | | -------- x1y1 -------- x3y3Parameters:
Name Type Description x0number Horizontal coordinate of P0. y0number Vertical coordinate of P0. x1number Horizontal coordinate of P1. y1number Vertical coordinate of P1. x2number Horizontal coordinate of P2. y2number Vertical coordinate of P2. x3number Horizontal coordinate of P3. y3number Vertical coordinate of P3. - Source:
Returns:
- Type
- boolean
-
<static> uniformRandom(a, b) → {number}
-
Generates a random number between [a, b] interval.
Parameters:
Name Type Description anumber bnumber - Source:
Returns:
- Type
- number