magnitudeSquared

Returns the squared magnitude (Euclidean length) of a Vector.

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

Examples

assert(Vec2(0, 0).magnitudeSquared() == 0);
assert(Vec2(1, 0).magnitudeSquared() == 1);
assert(Vec2(0, 1).magnitudeSquared() == 1);
assert(Vec2(1, 1).magnitudeSquared() == 2);
assert(Vec2(2, 0).magnitudeSquared() == 4);
assert(Vec2(1, 2).magnitudeSquared() == 5);

Meta