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:
The geometric transformation matrix T
is represented by a 3-by-3 matrix:
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:
The geometric transformation matrix A
is represented by a 3-by-3
matrix that is the transpose of matrix T
:
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.
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 Object Current Geometric Transformation Object affine2d
Use affinetform2d
instead. To create a 2-D affine transformation that represents a purely rigid, similar, or translation transformation, userigidtform2d
,simtform2d
, ortransltform2d
, respectively.affine3d
Use affinetform3d
instead. To create a 3-D affine transformation that represents a purely rigid, similar, or translation transformation, userigidtform3d
,simtform3d
, ortransltform3d
, respectively.rigid2d
Use rigidtform2d
instead. To create a 2-D rigid transformation that represents pure translation, usetransltform2d
.rigid3d
Use rigidtform3d
instead. To create a 3-D rigid transformation that represents pure translation, usetransltform3d
.projective2d
Use projtform2d
instead.Create the object using the transpose of the transformation matrix stored in the old object. For example, this code shows how to convert a 2-D affine transformation represented by an
affine2d
object namedtformPost
to anaffinetform2d
object namedtformPre
.T = tformPost.T; A = T'; tformPre = affinetform2d(A);