# simtform2d

2-D similarity geometric transformation

Since R2022b

## Description

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

## Creation

You can create a `simtform2d` object in these ways:

• `fitgeotform2d` — Estimate a geometric transformation that maps pairs of control points between two images.

• The `simtform2d` function described here.

### Syntax

``tform = simtform2d``
``tform = simtform2d(Scale,RotationAngle,Translation)``
``tform = simtform2d(Scale,R,Translation)``
``tform = simtform2d(A)``
``tform = simtform2d(tformIn)``

### Description

````tform = simtform2d` creates a `simtform2d` object that performs the identity transformation.```
````tform = simtform2d(Scale,RotationAngle,Translation)` creates a `simtform2d` object that performs a similarity transformation based on the specified values of the `Scale`, `RotationAngle`, and `Translation` properties. These properties specify the scale factor, rotation angle, and the amount of translation in the x- and y-directions, respectively.```

example

````tform = simtform2d(Scale,R,Translation)` creates a `simtform2d` object that performs a similarity transformation based on the specified values of the `Scale`, `R`, and `Translation` properties. These properties indicate the scale factor, rotation matrix, and the amounts of translation in the x- and y-directions.```
````tform = simtform2d(A)` creates a `simtform2d` object and sets the property `A` as the specified 2-D similarity transformation matrix.```
````tform = simtform2d(tformIn)` creates a `simtform2d` object from another geometric transformation object, `tformIn`, that represents a valid 2-D similarity geometric transformation.```

### Input Arguments

expand all

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

## Properties

expand all

Forward 2-D similarity transformation, specified as a 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 similarity transformation, `A` has the form:

`$Α=\left[\begin{array}{ccc}s×\mathrm{cosd}\left(r\right)& -s×\mathrm{sind}\left(r\right)& {t}_{x}\\ s×\mathrm{sind}\left(r\right)& s×\mathrm{cosd}\left(r\right)& {t}_{y}\\ 0& 0& 1\end{array}\right]$`

where s is the scale factor and corresponds to the `Scale` property. r is the rotation angle and corresponds to the `RotationAngle` property. 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`

Scale factor, specified as a positive number. The scale factor corresponds to the value s in the similarity transformation matrix defined by property `A`.

Data Types: `double` | `single`

Rotation matrix, specified as a 2-by-2 numeric matrix. The matrix must have the form

` R = [cosd(r) -sind(r); sind(r) cosd(r)]`
where r is the value of the `RotationAngle` property.

Rotation angle about the origin in degrees, specified as a numeric scalar in the range [-180, 180). If you specify a rotation angle outside of this range, then the `simtform2d` object automatically brings the value to the range [-180, 180) by adding positive or negative multiples of 360.

The rotation angle corresponds to the value r in the transformation matrix defined by `A` and in the rotation matrix defined by `R`.

Data Types: `double` | `single`

Amount of translation, specified as a 2-element numeric vector of the form [tx ty]. These amounts of translation correspond to the values tx and ty in the similarity transformation matrix defined by `A`.

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 scale factor, rotation angle, and the amount of translation.

```scaleFactor = 3; theta = 30; translation = [10 20.5];```

Create a `simtform2d` object that performs the specified scaling, rotation, and translation.

`tform = simtform2d(scaleFactor,theta,translation)`
```tform = simtform2d with properties: Dimensionality: 2 Scale: 3 RotationAngle: 30 Translation: [10 20.5000] R: [2x2 double] A: [2.5981 -1.5000 10.0000 1.5000 2.5981 20.5000 0 0 1.0000] ```

Examine the value of the `A` property.

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

## Version History

Introduced in R2022b

expand all