Structure

# CGAffineTransform

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

## Overview

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:

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’):

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.

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.

## Topics

### Instance Properties

`a`

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

`b`

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

`c`

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

`d`

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

`tx`

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

`ty`

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

### Geometric Data Types

`CGPoint`

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

`CGSize`

A structure that contains width and height values.

`CGRect`

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

`CGVector`

A structure that contains a two-dimensional vector.