Main Content


3-D affine geometric transformation


    An affinetform3d object stores information about a 3-D affine geometric transformation and enables forward and inverse transformations.


    You can create an affinetform3d object in these ways:

    • imregtform — Estimates a geometric transformation that maps a moving image to a fixed image using similarity optimization.

    • randomAffine3d — Creates a randomized 3-D affine transformation.

    • The affinetform3d function described here.


    tform = affinetform3d creates an affinetform3d object that performs an identity transformation.


    tform = affinetform3d(A) creates an affinetform3d object and sets the property A as the specified 3-D affine transformation matrix.

    tform = affinetform3d(tformIn) creates an affinetform3d object from another geometric transformation object, tformIn, that represents a valid 3-D affine geometric transformation.

    Input Arguments

    expand all

    Affine 3-D geometric transformation, specified as an affinetform3d object, rigidtform3d object, simtform3d object, or transltform3d object.


    expand all

    Forward 3-D affine transformation, specified as a nonsingular 4-by-4 numeric matrix. The default value of A is the identity matrix.

    The matrix A transforms the point (u, v, w) in the input coordinate space to the point (x, y, z) in the output coordinate space using the convention:


    For an affine transformation, A has the form:


    Data Types: double | single

    This property is read-only.

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

    Data Types: double

    Object Functions

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


    collapse all

    Define a 4-by-4 geometric transformation matrix. This matrix specifies an affine transformation consisting of translation and nonisotropic scaling.

    [sx,sy,sz] = deal(2,2,2.5);
    [tx,ty,tz] = deal(10,20.5,15);
    A = [sx 0 0 tx; 0 sy 0 ty; 0 0 sz tz; 0 0 0 1];

    Create an affinetform3d object that performs the scaling and translation.

    tform = affinetform3d(A)
    tform = 
      affinetform3d with properties:
        Dimensionality: 3
                     A: [4x4 double]

    Examine the value of the A property.

    ans = 4×4
        2.0000         0         0   10.0000
             0    2.0000         0   20.5000
             0         0    2.5000   15.0000
             0         0         0    1.0000

    Extended Capabilities

    Version History

    Introduced in R2022b

    expand all