Constructor
new MathUtils()
Methods
(static) clamp(value, min, max) → {Number}
Clamps the value to be between min and max.
Parameters:
Name | Type | Description |
---|---|---|
value | Number | Value to be clamped. |
min | Number | The minimum value. |
max | Number | The maximum value. |
Returns:
- The clamped value.
- Type:
- Number
(static) denormalize(value, array) → {Number}
Denormalizes a value based on the type of the provided array.
Parameters:
Name | Type | Description |
---|---|---|
value | Number | The value to be denormalized. |
array | TypedArray | The typed array to determine the normalization factor. |
Throws:
- - Throws an error if the array type is invalid.
- Type
- Error
Returns:
- The denormalized value.
- Type:
- Number
(static) euclideanModulo(n, m) → {Number}
Compute euclidean modulo of m % n. Refer to: https://en.wikipedia.org/wiki/Modulo_operation
Parameters:
Name | Type | Description |
---|---|---|
n | Number | The dividend. |
m | Number | The divisor. |
Returns:
- The result of the modulo operation.
- Type:
- Number
(static) generateUUID() → {String}
Method for generate uuid. http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
Returns:
- The uuid.
- Type:
- String
(static) isPowerOfTwo(value) → {Boolean}
Is this number a power of two.
Parameters:
Name | Type | Description |
---|---|---|
value | Number | The input number. |
Returns:
- Is this number a power of two.
- Type:
- Boolean
(static) lerp(x, y, t) → {Number}
Returns a value linearly interpolated from two known points based on the given interval - t = 0 will return x and t = 1 will return y.
Parameters:
Name | Type | Description |
---|---|---|
x | Number | The first value. |
y | Number | The second value. |
t | Number | The interpolation factor. |
Returns:
- The interpolated value.
- Type:
- Number
(static) nearestPowerOfTwo(value) → {Number}
Return the nearest power of two number of this number.
Parameters:
Name | Type | Description |
---|---|---|
value | Number | The input number. |
Returns:
- The result number.
- Type:
- Number
(static) nextPowerOfTwo(value) → {Number}
Return the next power of two number of this number.
Parameters:
Name | Type | Description |
---|---|---|
value | Number | The input number. |
Returns:
- The result number.
- Type:
- Number
(static) normalize(value, array) → {Number}
Normalizes a value based on the type of the provided array.
Parameters:
Name | Type | Description |
---|---|---|
value | Number | The value to be normalized. |
array | TypedArray | The typed array to determine the normalization factor. |
Throws:
- - Throws an error if the array type is invalid.
- Type
- Error
Returns:
- The normalized value.
- Type:
- Number