# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

# affine2d class

2-D Affine Geometric Transformation

## Description

An `affine2d` object encapsulates a 2-D affine geometric transformation.

Code Generation support: Yes.

MATLAB Function Block support: Yes.

## Construction

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

`tform = affine2d(A)` creates an `affine2d` object given an input 3-by-3 matrix `A` that specifies a valid affine transformation.

### Input Arguments

 `A` 3-by-3 matrix that specifies a valid affine transformation of the form: ```A = [a b 0; c d 0; e f 1]; ```Default: Identity transformation

## Properties

 `T` 3-by-3 double-precision, floating point matrix that defines the 2-D forward affine transformation 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]; ``` `Dimensionality` Describes the dimensionality of the geometric transformation for both input and output points

## Methods

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

## Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® documentation.

## Examples

expand all

Create an `affine2d` object that defines the transformation.

```theta = 10; 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 forward geometric transformation to an input (`U`,`V`) point (5,10).

`[X,Y] = transformPointsForward(tform,5,10)`
```X = 6.6605 Y = 8.9798```

Apply inverse geometric transformation to output (`X`,`Y`) point from the previous step to recover the original points from the inverse transformation.

`[U,V] = transformPointsInverse(tform,X,Y)`
```U = 5.0000 V = 10 ```

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

Create an `affine2d` object that defines the transformation.

```theta = 10; 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 geometric transformation to image.

```outputImage = imwarp(A,tform); figure, imshow(outputImage);```

### Code Generation

This function supports the generation of C code using MATLAB Coder™. For more information, see Code Generation for Image Processing.

When generating code, you can only specify singular objects—arrays of objects are not supported.

### MATLAB Function Block

You can use this function in the MATLAB Function Block in Simulink.