API reference / @jsprismarine/math
@jsprismarine/math
JSPrismarine math utilities.
Classes
Functions
hypot3()
hypot3(
x,y,z):number
Defined in: hypot3.ts:14
The Euclidean length of a three component vector, bit-identical to Math.hypot(x, y, z).
V8 runs Math.hypot through a general variadic builtin. This is the same algorithm for exactly three arguments: scale by the largest magnitude, sum the squares with Kahan compensation, take the root and scale back. That order is what keeps the result equal to Math.hypot's in the last bit, which Math.sqrt(x * x + y * y + z * z) does not: that one differs for about a third of inputs, and a distance compared against a threshold would change digests.
Parameters
x
number
The first component.
y
number
The second component.
z
number
The third component.
Returns
number
The same number Math.hypot(x, y, z) returns, including for zero, infinite and NaN inputs.