Main Content

rigid2d

(Not recommended) 2-D rigid geometric transformation using postmultiply convention

Since R2020b

rigid2d is not recommended. Use the rigidtform2d object instead. For more information, see Compatibility Considerations.

Description

A rigid2d object stores information about a 2-D rigid geometric transformation and enables forward and inverse transformations.

Creation

Description

tform = rigid2d creates a default rigid2d object that corresponds to an identity transformation.

tform = rigid2d(t) sets the T property as the specified 2-D rigid transformation matrix t.

example

tform = rigid2d(rot,trans) sets the Rotation and Translation properties as the specified rotation matrix rot and translation vector trans, respectively.

Properties

expand all

Forward rigid transformation, specified as a 3-by-3 numeric matrix. The matrix T satisfies the postmultiply convention given by:

[x y 1] = [u v 1] * Rotation + Translation

Data Types: single | double

Rotation component of the transformation, specified as a 2-by-2 numeric matrix.

Data Types: single | double

Translation component of the transformation, specified as a 2-element numeric row vector.

Data Types: single | double

This property is read-only.

Dimensionality of the geometric transformation, specified as the number 2.

Object Functions

invertInvert geometric transformation
isTranslationDetermine if geometric transformation is pure translation
outputLimitsFind output spatial limits given input spatial limits
transformPointsForwardApply forward geometric transformation
transformPointsInverseApply inverse geometric transformation

Examples

collapse all

Specify an angle of rotation in degrees and create a 2-by-2 rotation matrix.

theta = 30;
rot = [ cosd(theta) sind(theta); ...
       -sind(theta) cosd(theta)];

Specify the amount of horizontal and vertical translation, respectively.

trans = [2 3];

Create a rigid2d object that performs the rotation and translation.

tform = rigid2d(rot,trans)
tform = 
  rigid2d with properties:

       Rotation: [2x2 double]
    Translation: [2 3]

Extended Capabilities

Version History

Introduced in R2020b

collapse all

R2022b: Not recommended

Starting in R2022b, most Image Processing Toolbox™ functions create and perform geometric transformations using the premultiply convention. Accordingly, the rigid2d object is not recommended because it uses the postmultiply convention. Although there are no plans to remove the rigid2d object at this time, you can streamline your geometric transformation workflows by switching to the rigidtform2d object, which supports the premultiply convention. For more information, see Migrate Geometric Transformations to Premultiply Convention.

To update your code:

  • Change instances of the function name rigid2d to rigidtform2d.

  • Specify the transformation matrix as the transpose of the matrix T or Rotation. T is either the value of the T property of the rigid2d object or the transformation matrix used to create the rigid2d object. Rotation is either the value of the Rotation property of the rigid2d object or the rotation matrix used to create the rigid2d object.

Discouraged UsageRecommended Replacement

This example creates a rigid2d object from transformation matrix T in the postmultiply convention.

T = [1 0 0; 0 1 0; 5 10 1];
tformPost = rigid2d(T);

This example creates a rigidtform2d object from the transpose of the transformation matrix T.

T = [1 0 0; 0 1 0; 5 10 1];
tform = rigidtform2d(T');

This example starts with a rigid2d object called tformPost and creates a rigidtform2d object from the transpose of the T property of tformPost.

T = tformPost.T;
tform = rigidtform2d(T');

This example creates a rigid2d object from a rotation matrix rot in the postmultiply convention and a translation trans.

theta = 45;
rot = [cosd(theta) sind(theta); -sind(theta) cosd(theta)];
trans = [5 10];
tformPost = rigid2d(rot,trans);

This example creates a rigidtform2d object from the transpose of the rotation matrix rot and a translation trans.

theta = 45;
rot = [cosd(theta) sind(theta); -sind(theta) cosd(theta)];
trans = [5 10];
tform = rigidtform2d(rot',trans);

You can simplify your code by specifying the angle of rotation directly.

tform = rigidtform2d(theta,trans);