What actually length_sqr returns?

In vmath there is a length_sqr function which is said to return the squared length of a vector or quaternion. What is actually the squared length here?

1 Like

To calculate the length, you need to take the square root of the vector:

length = sqrt(x*x + y*y + z*z)

But sometimes, the actual length isn’t needed, you just need the vector dot’ed with itself. This skips the sqrt part of it, which is faster:

length_sqr = x*x + y*y + z*z
6 Likes

Thank you, I understood

2 Likes