# transltform2d

2-D translation geometric transformation

## Description

A `transltform2d` object stores information about a 2-D translation geometric transformation and enables forward and inverse transformations.

## Creation

### Syntax

``tform = transltform2d``
``tform = transltform2d(Translation)``
``tform = transltform2d(tx,ty)``
``tform = transltform2d(A)``
``tform = transltform2d(tformIn)``

### Description

````tform = transltform2d` creates a `transltform2d` object that performs the identity transformation.```

example

````tform = transltform2d(Translation)` creates a `transltform2d` object that performs a translation transformation based on the specified value of the `Translation` property. This property specifies the amount of translation in the x- and y-directions.```
````tform = transltform2d(tx,ty)` creates a `transltform2d` object that performs a translation transformation with the specified amounts of translation `tx` and `ty` in the x- and y-directions, respectively.```
````tform = transltform2d(A)` creates a `transltform2d` object and sets the property `A` as the specified 2-D translation transformation matrix.```
````tform = transltform2d(tformIn)` creates a `transltform2d` object from another geometric transformation object, `tformIn`, that represents a valid 2-D translation geometric transformation.```

### Input Arguments

expand all

Amount of translation in the x-direction, specified as a numeric scalar. This value sets the first element of the `Translation` property.

Amount of translation in the y-direction, specified as a numeric scalar. This value sets the second element of the `Translation` property

Translation 2-D geometric transformation, specified as an `affinetform2d` object, `rigidtform2d` object, `simtform2d` object, `transltform2d` object, or `projtform2d` object.

## Properties

expand all

Forward 2-D translation transformation, specified as a nonsingular 3-by-3 numeric matrix. When you create the object, you can also specify `A` as a 2-by-3 numeric matrix. In this case, the object concatenates the row vector ```[0 0 1]``` to the end of the matrix, forming a 3-by-3 matrix. The default of `A` is the identity matrix.

The matrix `A` transforms the point (u, v) in the input coordinate space to the point (x, y) in the output coordinate space using the convention:

`$\left[\begin{array}{c}x\\ y\\ 1\end{array}\right]=Α×\left[\begin{array}{c}u\\ v\\ 1\end{array}\right]$`

For a translation transformation, `A` has the form:

`$Α=\left[\begin{array}{ccc}1& 0& {t}_{x}\\ 0& 1& {t}_{y}\\ 0& 0& 1\end{array}\right]$`

where tx and ty are the amount of translation in the x- and y-directions, respectively, and correspond to the `Translation` property.

Data Types: `double` | `single`

Amount of translation, specified as a 2-element numeric vector of the form [tx ty].

Data Types: `double` | `single`

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

Data Types: `double`

## Object Functions

 `invert` Invert geometric transformation `outputLimits` Find output spatial limits given input spatial limits `transformPointsForward` Apply forward geometric transformation `transformPointsInverse` Apply inverse geometric transformation

## Examples

collapse all

Specify the amount of translation.

`t = [10 20.5];`

Create a `transltform2d` object that performs the specified translation.

`tform = transltform2d(t)`
```tform = transltform2d with properties: Dimensionality: 2 Translation: [10 20.5000] A: [3x3 double] ```

Examine the value of the `A` property.

`tform.A`
```ans = 3×3 1.0000 0 10.0000 0 1.0000 20.5000 0 0 1.0000 ```

## Version History

Introduced in R2022b