Buggy CATransform3D?

The following code is just an example how does it work:

CATransform3D temp = CATransform3DIdentity;
temp.m34 = -0.002;
temp = CATransform3DTranslate(transform, 0, 0, 0);

The output after the second line of code:

(lldb) po temp
 (m11 = 1, m12 = 0, m13 = 0, m14 = 0, m21 = 0, m22 = 1, m23 = 0, m24 = 0, m31 = 0, m32 = 0, m33 = 1, m34 = -0.00200000009, m41 = 0, m42 = 0, m43 = 0, m44 = 1)

The output after the third 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 = 186.073914, m43 = -135.190613, m44 = 1.27038121)

Whats the …? The third 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.

So I just wrote a multiplication on an identity matrix which is already incorrect but in my app there are more complex calculations which “break” the transform matrix and which I can’t replace with CATRansform3DIdentity. Could anybody suggest a solution how to generate correct matrices (m44 == 1) except of multiplicating them manually?


Source: ios

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.