new MathUtils()
Methods
-
static area(a, b, c) → {Number}
-
Computes the signed area of a rectangle defined by three points. This method can also be used to calculate the area of a triangle.
Parameters:
Name Type Description aVector3 The first point in 3D space.
bVector3 The second point in 3D space.
cVector3 The third point in 3D space.
Returns:
Number -The signed area.
-
static argmax(array) → {Array.<Number>}
-
Returns the indices of the maximum values of the given array.
Parameters:
Name Type Description arrayArray.<Number> The input array.
Returns:
Array.<Number> -Array of indices into the array.
-
static choice(array, probabilities) → {Any}
-
Returns a random sample from a given array.
Parameters:
Name Type Default Description arrayArray.<Any> The array that is used to generate the random sample.
probabilitiesArray.<Number> null The probabilities associated with each entry. If not given, the sample assumes a uniform distribution over all entries.
Returns:
Any -The random sample value.
-
static clamp(value, min, max) → {Number}
-
Ensures the given scalar value is within a given min/max range.
Parameters:
Name Type Description valueNumber The value to clamp.
minNumber The min value.
maxNumber The max value.
Returns:
Number -The clamped value.
-
static generateUUID() → {String}
-
Computes a RFC4122 Version 4 complied Universally Unique Identifier (UUID).
Returns:
String -The UUID.
-
static randFloat(min, max) → {Number}
-
Computes a random float value within a given min/max range.
Parameters:
Name Type Description minNumber The min value.
maxNumber The max value.
Returns:
Number -The random float value.
-
static randInt(min, max) → {Number}
-
Computes a random integer value within a given min/max range.
Parameters:
Name Type Description minNumber The min value.
maxNumber The max value.
Returns:
Number -The random integer value.