Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

decomposeAffine

Decompose an affine matrix into its constituent transformations


Description

An affine matrix is composed of translation, scale, skew and rotation transformations. This function extracts these components, after first inverting the matrix so that it transforms from source to target space.

Usage

decomposeAffine(affine)

Arguments

affine

A 4x4 matrix representing an affine transformation matrix.

Value

A list with components:

scaleMatrix

A 3x3 matrix representing only the scale operation embodied in the full affine transformation.

skewMatrix

A 3x3 matrix representing only the skew operation embodied in the full affine transformation.

rotationMatrix

A 3x3 matrix representing only the rotation operation embodied in the full affine transformation.

translation

A length-3 named numeric vector representing the translations (in pixunits units) in each of the X, Y and Z directions.

scales

A length-3 named numeric vector representing the scale factors in each of the X, Y and Z directions. Scale factors of 1 represent no effect.

skews

A length-3 named numeric vector representing the skews in each of the XY, XZ and YZ planes.

angles

A length-3 named numeric vector representing the rotation angles (in radians) about each of the X, Y and Z directions, i.e., roll, pitch and yaw.

Note

The decomposition is not perfect, and there is one particular degenerate case when the pitch angle is very close to pi/2 radians, known as “Gimbal lock”. In this case the yaw angle is arbitrarily set to zero.

Affine matrices embodying rigid-body transformations include only 6 degrees of freedom, rather than the full 12, so skews will always be zero and scales will always be unity (to within rounding error). Likewise, affine matrices derived from 2D registration will not include components relating to the Z direction.

Author(s)

Jon Clayden <code@clayden.org>

See Also


RNiftyReg

Image Registration Using the 'NiftyReg' Library

v2.7.0
GPL-2
Authors
Jon Clayden [cre, aut] (<https://orcid.org/0000-0002-6608-0619>), Marc Modat [aut], Benoit Presles [aut], Thanasis Anthopoulos [aut], Pankaj Daga [aut]
Initial release
2020-09-10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.