Members
0.1
0.01
0.001
0.0001
0.00001
0.000001
1e-7
1e-8
1e-9
1e-10
1e-11
1e-12
1e-13
1e-14
1e-15
Methods
Constraint a value to lie between two values.
Name | Type | Description |
---|---|---|
value |
Number |
The value to clamp. |
min |
Number |
The minimum value. |
max |
Number |
The maximum value. |
Returns:
The clamped value such that min <= result <= max.
Determines if two values are equal using an absolute or relative tolerance test. This is useful to avoid problems due to roundoff error when comparing floating-point values directly. The values are first compared using an absolute tolerance test. If that fails, a relative tolerance test is performed. Use this test if you are unsure of the magnitudes of left and right.
Name | Type | Default | Description |
---|---|---|---|
left |
Number |
The first value to compare. |
|
right |
Number |
The other value to compare. |
|
relativeEpsilon |
Number |
0
|
optional
The maximum inclusive delta between |
absoluteEpsilon |
Number |
relativeEpsilon
|
optional
The maximum inclusive delta between |
Returns:
true
if the values are equal within the epsilon; otherwise, false
.
Example:
const a = equalsEpsilon(0.0, 0.01, EPSILON2); // true
const b = equalsEpsilon(0.0, 0.1, EPSILON2); // false
const c = equalsEpsilon(3699175.1634344, 3699175.2, EPSILON7); // true
const d = equalsEpsilon(3699175.1634344, 3699175.2, EPSILON9); // false
Computes the linear interpolation of two values.
Name | Type | Description |
---|---|---|
p |
Number |
The start value to interpolate. |
q |
Number |
The end value to interpolate. |
time |
Number |
The time of interpolation generally in the range |
Returns:
The linearly interpolated value.
Example:
const n = Math.lerp(0.0, 2.0, 0.5); // returns 1.0
Converts radians to degrees.
Name | Type | Description |
---|---|---|
radians |
Number |
The angle to convert in radians. |
Returns:
The corresponding angle in degrees.
Converts degrees to radians.
Name | Type | Description |
---|---|---|
degrees |
Number |
The angle to convert in degrees. |
Returns:
The corresponding angle in radians.