EDITED
(the example contained mistake so I replaced it with another one)
The following code is just an example how does it work:
CATransform3D temp = CATransform3DIdentity;
temp.m34 = -0.002;
temp = CATransform3DTranslate(temp, 0, -230, 0);
temp = CATransform3DRotate(temp, -M_PI / 5, 1, 0, 0);
temp = CATransform3DTranslate(temp, 0, 230, 0);
The output before the last line of code:
(lldb) po temp
(m11 = 1, m12 = 0, m13 = 0, m14 = 0, m21 = 0, m22 = 0.809017002, m23 = -0.587785244, m24 = 0.00117557053, m31 = 0, m32 = 0.587785244, m33 = 0.809017002, m34 = -0.00161803409, m41 = 0, m42 = -230, m43 = 0, m44 = 1)
The output after the last line of code:
(lldb) po temp
(m11 = 1, m12 = 0, m13 = 0, m14 = 0, m21 = 0, m22 = 0.809017002, m23 = -0.587785244, m24 = 0.00117557053, m31 = 0, m32 = 0.587785244, m33 = 0.809017002, m34 = -0.00161803409, m41 = 0, m42 = -43.9260902, m43 = -135.190613, m44 = 1.27038121)
Whats the ...? The last line of code does nothing because it is E
(it is indentation matrix and multiplication with it should return the same result) but it have changed even the m44 element which must be always equal to 1.
And even if this matrix performs the same calculations as the correct one does then, for example, I can't simply take back a transform value which is stored in it.
Could anybody suggest a solution how to generate correct matrices (m44 == 1) except of multiplicating them manually?
I have found a reason of the problem. Everything is correct because in CATransform3D
all the transform matrices are transposed but I thought that they look like the following one:
So m44 != 1
because m34 is not the z
coordinate or another kind of translation. It means "perspective" which has influence on m44
value. It also tangled me that m44 == 1
until the last line of code.