Main Content

rigidtform2d

2-D rigid geometric transformation

Since R2022b

    Description

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

    Creation

    Description

    tform = rigidtform2d creates a rigidtform2d object that performs an identity transformation.

    tform = rigidtform2d(Translation) creates a rigidtform2d object that performs a rigid transformation consisting only of translation. The specified property Translation indicates the amount of translation in the x- and y-directions.

    If you want a transformation that performs only 2-D translation, consider using the transltform2d object.

    example

    tform = rigidtform2d(RotationAngle,Translation) creates a rigidtform2d object that performs a rigid transformation based on the specified values of the RotationAngle and Translation properties. These properties indicate the rotation angle and the amount of translation in the x- and y- directions.

    tform = rigidtform2d(R,Translation) creates a rigidtform2d object that performs a rigid transformation based on the specified values of the R and Translation properties. These properties indicate the rotation matrix and the amount of translation in the x- and y- directions.

    tform = rigidtform2d(A) creates a rigidtform2d object and sets the property A as the specified 2-D rigid transformation matrix.

    tform = rigidtform2d(tformIn) creates a rigidtform2d object from another geometric transformation object, tformIn, that represents a valid 2-D rigid geometric transformation.

    Input Arguments

    expand all

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

    Properties

    expand all

    Forward 2-D rigid 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 value 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:

    [xy1]=Α×[uv1]

    For a rigid transformation, A has the form:

    Α=[cosd(r)sind(r)txsind(r)cosd(r)ty001]

    where r is the rotation angle and corresponds to the property RotationAngle. tx and ty are the amount of translation in the x- and y- directions, respectively, and correspond to the property Translation.

    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. 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 rigid transformation matrix defined by A.

    Data Types: double | single

    This property is read-only.

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

    Data Types: double

    Object Functions

    invertInvert geometric transformation
    outputLimitsFind output spatial limits given input spatial limits
    transformPointsForwardApply forward geometric transformation
    transformPointsInverseApply inverse geometric transformation

    Examples

    collapse all

    Specify a rotation angle and an amount of translation.

    theta = 30;
    translation = [10 20.5];

    Create a rigidtform2d object that performs the specified rotation and translation.

    tform = rigidtform2d(theta,translation)
    tform = 
      rigidtform2d with properties:
    
        Dimensionality: 2
         RotationAngle: 30
           Translation: [10 20.5000]
                     R: [2x2 double]
    
                     A: [0.8660   -0.5000   10.0000
                         0.5000    0.8660   20.5000
                              0         0    1.0000]
    
    

    Examine the value of the A property.

    tform.A
    ans = 3×3
    
        0.8660   -0.5000   10.0000
        0.5000    0.8660   20.5000
             0         0    1.0000
    
    

    Extended Capabilities

    Version History

    Introduced in R2022b

    expand all