Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# affine3d class

3-D Affine Geometric Transformation

## Description

An affine3d object encapsulates a 3-D affine geometric transformation.

## Construction

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

tform = affine3d(A) constructs an affine3d object given an input 4-by-4 matrix A that specifies a valid 4-by-4 affine transformation matrix.

### Input Arguments

 A A 4-by-4 matrix that specifies a valid affine transformation of the form ``` A = [a b c 0; d e f 0; g h i 0; j k l 1]; ```Default: Identity transformation

## Properties

 T 4-by-4 double-precision floating point matrix that defines the 3-D forward transformation. 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];``` Default: Identity transformation Dimensionality Describes the dimensionality of the geometric transformation for both input and output points.

## Methods

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

## Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® documentation.

## Examples

expand all

### Define a Different Scale Factor in Each Dimension

Create an affine3d object that defines a different scale factor in each dimension.

```Sx = 1.2;
Sy = 1.6;
Sz = 2.4;
tform = affine3d([Sx 0 0 0; 0 Sy 0 0; 0 0 Sz 0; 0 0 0 1]);```
```tform =

affine3d with properties:

T: [4x4 double]
Dimensionality: 3```

Apply forward geometric transformation to an input point.

`[X,Y,Z] = transformPointsForward(tform,1,1,1)`
```X =

1.2000

Y =

1.6000

Z =

2.4000```

Apply inverse geometric transformation to output points from the previous step to recover the original points from the inverse transformation.

`[U,V,W] = transformPointsInverse(tform,X,Y,Z)`
```U =

1

V =

1

W =

1```

### Apply Scale Transformation to an MRI Volume Using imwarp Function

```A = load('mri');
A = squeeze(A.D);```

Create an affine3d object that defines a different scale factor in each dimension.

```Sx = 1.2;
Sy = 1.6;
Sz = 2.4;
tform = affine3d([Sx 0 0 0; 0 Sy 0 0; 0 0 Sz 0; 0 0 0 1]);```
```tform =

affine3d with properties:

T: [4x4 double]
Dimensionality: 3
```

Apply geometric transformation to image using imwarp and visualize axial slice through center of transformed volume to see effect of scale transformation.

```outputImage = imwarp(A,tform);
figure, imshowpair(A(:,:,14),outputImage(:,:,27));```