# affine2d

(Not recommended) 2-D affine geometric transformation using postmultiply convention

`affine2d` is not recommended. Use the `affinetform2d` object instead. For more information, see Compatibility Considerations.

## Description

An `affine2d` object stores information about a 2-D affine geometric transformation using the postmultiply convention, and enables forward and inverse transformations.

## Creation

### Syntax

``tform = affine2d``
``tform = affine2d(t)``

### Description

````tform = affine2d` creates an `affine2d` object with default property settings that correspond to the identity transformation.```

example

````tform = affine2d(t)` sets the property `T` as the specified 2-D affine transformation matrix `t`.```

## Properties

expand all

Forward 2-D affine transformation, specified as a nonsingular 3-by-3 numeric matrix. The matrix `T` uses the convention:

`[x y 1] = [u v 1] * T`

where `T` has the form:

``` [a b 0; c d 0; e f 1]; ```

The default of `T` is the identity transformation.

Data Types: `double` | `single`

Dimensionality of the geometric transformation for both input and output points, specified as the value `2`.

## Object Functions

 `invert` Invert geometric transformation `isRigid` Determine if geometric transformation is rigid transformation `isSimilarity` Determine if geometric transformation is similarity transformation `isTranslation` Determine if geometric transformation is pure translation `outputLimits` Find output spatial limits given input spatial limits `transformPointsForward` Apply forward geometric transformation `transformPointsInverse` Apply inverse geometric transformation

## Examples

collapse all

Create an `affine2d` object that defines a 30 degree rotation in the counterclockwise direction around the origin.

```theta = 30; tform = affine2d([ ... cosd(theta) sind(theta) 0;... -sind(theta) cosd(theta) 0; ... 0 0 1])```
```tform = affine2d with properties: T: [3x3 double] Dimensionality: 2 ```

Apply the forward geometric transformation to a point (10,0).

`[x,y] = transformPointsForward(tform,10,0)`
```x = 8.6603 ```
```y = 5 ```

Validate the transformation by plotting the original point (in blue) and the transformed point (in red).

```plot(10,0,'bo',x,y,'ro') axis([0 12 0 12]) axis square``` Read an image into the workspace.

`A = imread('pout.tif');`

Create an `affine2d` object that defines an affine geometric transformation. This example combines vertical shear and horizontal stretch.

`tform = affine2d([2 0.33 0; 0 1 0; 0 0 1])`
```tform = affine2d with properties: T: [3x3 double] Dimensionality: 2 ```

Apply the geometric transformation to the image using `imwarp`.

`B = imwarp(A,tform);`

Display the resulting image.

```figure imshow(B); axis on equal;``` ## Version History

Introduced in R2013a

expand all