C++ three-dimensional transformation