An affine transformation matrix for use in drawing 2D graphics.


typedef struct CGAffineTransform {
} CGAffineTransform;


An affine transformation matrix is used to rotate, scale, translate, or skew the objects you draw in a graphics context. The CGAffineTransform type provides functions for creating, concatenating, and applying affine transformations.

Affine transforms are represented by a 3 by 3 matrix:

A 3 by 3 matrix.

Because the third column is always (0,0,1), the CGAffineTransform data structure contains values for only the first two columns.

Conceptually, an affine transform multiplies a row vector representing each point (x,y) in your drawing by this matrix, producing a vector that represents the corresponding point (x’,y’):

A row vector multiplying a 3 by 3 matrix.

Given the 3 by 3 matrix, the following equations are used to transform a point (x, y) in one coordinate system into a resultant point (x’,y’) in another coordinate system.

Transformation equations.

The matrix thereby “links” two coordinate systems—it specifies how points in one coordinate system map to points in another.

Note that you do not typically need to create affine transforms directly. If you want only to draw an object that is scaled or rotated, for example, it is not necessary to construct an affine transform to do so. The most direct way to manipulate your drawing—whether by movement, scaling, or rotation—is to call the functions CGContextTranslateCTM, CGContextScaleCTM, or CGContextRotateCTM, respectively. You should generally only create an affine transform if you want to reuse it later.


Instance Properties


The entry at position [1,1] in the matrix.


The entry at position [1,2] in the matrix.


The entry at position [2,1] in the matrix.


The entry at position [2,2] in the matrix.


The entry at position [3,1] in the matrix.


The entry at position [3,2] in the matrix.

See Also

Geometric Data Types


A structure that contains a point in a two-dimensional coordinate system.


A structure that contains width and height values.


A structure that contains the location and dimensions of a rectangle.


A structure that contains a two-dimensional vector.