magnitude

Returns the magnitude (Euclidean length) of a Vector.

@safe @nogc nothrow
magnitude
(
T
uint N
)
(
const auto ref Vector!(T, N) vec
)
out (r) { assert (r >= 0, "Vector magnitude should be non-negative!"); }

Examples

assert(Vec2(0, 0).magnitude() == 0);
assert(Vec2(1, 0).magnitude() == 1);
assert(Vec2(0, 1).magnitude() == 1);
assert(Vec2(1, 1).magnitude() == sqrt(2f));
assert(Vec2(2, 0).magnitude() == 2);

Meta