Fixed 3D transformation calculation