magnitude of a vector in 2D and 3D