Main Content

transltform2d

2-D translation geometric transformation

Since R2022b

    Description

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

    Creation

    Description

    tform = transltform2d creates a transltform2d object that performs the identity transformation.

    tform = transltform2d(Translation) creates a transltform2d object that performs a translation transformation based on the specified value of the Translation property. This property specifies the amount of translation in the x- and y-directions.

    example

    tform = transltform2d(tx,ty) creates a transltform2d object that performs a translation transformation with the specified amounts of translation tx and ty in the x- and y-directions, respectively.

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

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

    Input Arguments

    expand all

    Amount of translation in the x-direction, specified as a numeric scalar. This value sets the first element of the Translation property.

    Amount of translation in the y-direction, specified as a numeric scalar. This value sets the second element of the Translation property

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

    Properties

    expand all

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

    [xy1]=Α×[uv1]

    For a translation transformation, A has the form:

    Α=[10tx01ty001]

    where 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

    Amount of translation, specified as a 2-element numeric vector of the form [tx ty].

    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 the amount of translation.

    t = [10 20.5];

    Create a transltform2d object that performs the specified translation.

    tform = transltform2d(t)
    tform = 
      transltform2d with properties:
    
        Dimensionality: 2
           Translation: [10 20.5000]
    
                     A: [1.0000         0   10.0000
                              0    1.0000   20.5000
                              0         0    1.0000]
    
    

    Examine the value of the A property.

    tform.A
    ans = 3×3
    
        1.0000         0   10.0000
             0    1.0000   20.5000
             0         0    1.0000
    
    

    Extended Capabilities

    Version History

    Introduced in R2022b