# affine3d

(Not recommended) 3-D affine geometric transformation using postmultiply convention

## Description

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

## Creation

### Description

tform = affine3d creates an affine3d object with default property settings that correspond to the identity transformation.

example

tform = affine3d(t) sets the property T as the specified 3-D affine transformation matrix t.

## Properties

expand all

Forward 3-D affine transformation, specified as a nonsingular 4-by-4 numeric matrix.

The matrix T uses the convention:

[x y z 1] = [u v w 1] * T

where T has the form:

[a b c 0;
d e f 0;
g h i 0;
j k l 1];

The default of T is the identity transformation.

Data Types: double | single

Describes the dimensionality of the geometric transformation for both input and output points, specified as the value 3.

## Object Functions

 invert Invert geometric transformation isRigid Determine if geometric transformation is rigid transformation isSimilarity Determine if geometric transformation is similarity transformation isTranslation Determine if geometric transformation is pure translation outputLimits Find output spatial limits given input spatial limits transformPointsForward Apply forward geometric transformation transformPointsInverse Apply inverse geometric transformation

## Examples

collapse all

Create an affine3d object that scales a 3-D image by a different factor in each dimension.

Sx = 1.2;
Sy = 1.6;
Sz = 2.4;
T = [Sx 0 0 0; 0 Sy 0 0; 0 0 Sz 0; 0 0 0 1];
tform = affine3d(T)
tform =
affine3d with properties:

T: [4x4 double]
Dimensionality: 3

Examine the value of the T property.

tform.T
ans = 4×4

1.2000         0         0         0
0    1.6000         0         0
0         0    2.4000         0
0         0         0    1.0000

## Version History

Introduced in R2013a

expand all

### R2022b: Not recommended

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

• Change instances of the function name affine3d to affinetform3d.

• Specify the transformation matrix as the transpose of the matrix T, where T is either the value of the T property of the affine3d object or the transformation matrix used to create the affine3d object.

Discouraged UsageRecommended Replacement

This example creates an affine3d object from transformation matrix T in the postmultiply convention.

T = [2 0 0 0; 0 2 0 0; 0 0 4 0; 5 10 -5 1];
tformPost = affine3d(T);

This example creates an affinetform3d object from the transpose of the transformation matrix T.

T = [2 0 0 0; 0 2 0 0; 0 0 4 0; 5 10 -5 1];
A = T';
tform = affinetform3d(A);

This example starts with an affine3d object called tformPost and creates an affinetform3d object from the transpose of the T property of tformPost.

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