How to get the magnitude of a vector