magnitude - nodef/extra-math GitHub Wiki

Calculate the magnitude (length) of a vector.

Alternatives: magnitude. Similar: magnitude.

function magnitude(xs)
// xs: vector ([x, y, z, ...])
const xmath = require('extra-math');


xmath.magnitude([5, 9]);
// → 10.295630140987

xmath.magnitude([10, 2, -1]);
// → 10.246950765959598

References