Migrate Geometric Transformations to Premultiply Convention

Starting in R2022b, functions that create and perform geometric transformations use a premultiply matrix convention.

A new set of objects enable geometric transformations using a premultiply convention. There are no plans to remove the old geometric transformation objects that support a postmultiply convention.

About the Premultiply and Postmultiply Conventions

Using the previous 2-D postmultiply matrix convention, you transform 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}{ccc}x& y& 1\end{array}\right]=\left[\begin{array}{ccc}u& v& 1\end{array}\right]\ast Τ$

The geometric transformation matrix T is represented by a 3-by-3 matrix:

$Τ=\left[\begin{array}{ccc}a& d& 0\\ b& e& 0\\ c& f& 1\end{array}\right]$

In the 2-D premultiply matrix convention, you transform 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]$

The geometric transformation matrix A is represented by a 3-by-3 matrix that is the transpose of matrix T:

$Α=\left[\begin{array}{ccc}a& b& c\\ d& e& f\\ 0& 0& 1\end{array}\right]$

Create New Geometric Transformation Objects from Previous Geometric Transformation Objects

If your code uses one of the previous geometric transformation objects, then you can update your code by using a new geometric transformation object that supports the premultiply convention.

1. Select a type of new geometric transformation object that performs your desired transformation. The affine and rigid postmultiply geometric transformation objects support multiple types of new premultiply geometric transformation objects. The table shows the available geometric transformations objects that you can use instead of the previous objects.

Previous Geometric Transformation ObjectCurrent Geometric Transformation Object
affine2dUse affinetform2d instead. To create a 2-D affine transformation that represents a purely rigid, similar, or translation transformation, use rigidtform2d, simtform2d, or transltform2d, respectively.
affine3dUse affinetform3d instead. To create a 3-D affine transformation that represents a purely rigid, similar, or translation transformation, use rigidtform3d, simtform3d, or transltform3d, respectively.
rigid2dUse rigidtform2d instead. To create a 2-D rigid transformation that represents pure translation, use transltform2d.
rigid3dUse rigidtform3d instead. To create a 3-D rigid transformation that represents pure translation, use transltform3d.