0

I'm running into some very weird behavior with CAAnimation that I'm trying to understand. I've managed to boil it down to a simple reproduction case:

  • Create a simple CAKeyframeAnimation with keyPath="transform"
  • Create a CATransform3D which is any multiple of the identity matrix (except 0 or 1). Let's say 0.5I for this example, so every diagonal entry is 0.5.
  • Set this matrix as the value for any number of frames.
  • Add the animation to some view's layer.

(Sorry, I'm working in Xamarin, so unfortunately no copy-paste Swift / ObjC code sample; I have exactly zero experience in these languages).

If you assign the transform I just described to a layer directly through (layer.transform = transform) it behaves as expected - nothing happens. The matrix is a multiple of the identity matrix, so after division over the homogeneous coordinate input / output points should be identical. As key frames of an animation, however, the matrix scales the layer to half its size (or whatever factor you chose).

I am stumped as to why this is happening and am hoping somebody can shed some light on this situation.

Elte Hupkes
  • 2,773
  • 2
  • 23
  • 18
  • I couldnt really understand but shouldnt 0.5I matrix supposed to halve the size? – cekisakurek Aug 07 '18 at 09:14
  • 4D (and 3D) homogeneous transformations are identical up to a scale factor because the result vectors are divided by their homogeneous coordinate. So, no, if `m44 = 0.5` as well, this is supposed to be an identity transformation in 3D space (in 4D space you would be right). To make sure I'm not going crazy about that I tried setting it as a regular transform property, which as I mentioned works as expected. – Elte Hupkes Aug 07 '18 at 09:54

0 Answers0