Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

measureLength

measureLength(x, y, z?): number

The length of the vector (x, y, z), or of (x, y) with z left out: the square root of the squares’ sum. ECMAScript defines *, + and Math.sqrt exactly and Math.hypot only approximately, so a room and every browser measure the same number here, where their Math.hypot can differ in the last digit. Overflows past about 1e154, which no length in a world reaches. A component under about 1e-154 loses precision when squared, and a vector of only such components measures 0 where Math.hypot would not. No component the step measures comes near: Rapier answers in 32-bit floats, the smallest about 1e-45, and a position differs from another by at least its last digit, about 1e-16 at a metre.

Parameter Type Default value
x number undefined
y number undefined
z number 0

number