lengthSq method
Computes the square of the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should compare the length squared instead as it is slightly more efficient to calculate.
Implementation
double lengthSq() {
return x * x + y * y + z * z;
}