Distance function in vector3D