views:

2488

answers:

2

Whats the difference between the two?

I'm sure they have pros and cons, and situations they are better performers in.

Any resources that compare the two?

Is one better for animation (I imagine the CATransform3D)? Why?

Also I think I read somewhere that text clarity can be an issue, is one better at scaling text?

+4  A: 

One is for linear 2d transformations, the other is for three dimensional projected transformations. At least that's what I could glean from the documentation.

If you don't need to render 3d projected onto the screen, use the affine transform. Otherwise, use the 3d transform. The 3d transform is essentially a 4x4 matrix, while the 2d affine one is 3x2.

MSN
2D Affine is usually 3 wide x 2 high (with an invisible implied identity in the bottom row).
plinth
+3  A: 

As MSN said, they are used in different cases. CGAffineTransform is used for 2-D manipulation of NSViews, UIViews, and other 2-D Core Graphics elements.

CATransform3D is a Core Animation structure that can do more complex 3-D manipulations of CALayers. CATransform3D has the same internal structure as an OpenGL model view matrix, which makes sense when you realize that Core Animation is built on OpenGL (CALayers are wrappers for OpenGL textures, etc.). I've found that this similarity of internal structure, combined with some nice helper functions that Apple provides, can let you do some neat OpenGL optimizations, as I post here.

When it comes down to choosing which do use, ask yourself if you're going to work with views directly in a 2-D space (CGAffineTransform) or with the underlying Core Animation layers in 3-D (CATransform3D). I use CATransform3D more frequently, but that's because I spend a lot of time with Core Animation.

Brad Larson