Transforming 3D and 4D vectors with matrices