bdv.util

## Class Affine3DHelpers

• public class Affine3DHelpers
extends Object
Helpers to extract parts (rotation, scale, etc) from AffineTransform3D. Note that most of these helpers assume additional restrictions on the affine transform.
Author:
Tobias Pietzsch <tobias.pietzsch@gmail.com>
• ### Constructor Detail

• #### Affine3DHelpers

public Affine3DHelpers()
• ### Method Detail

• #### extractRotation

public static void extractRotation(AffineTransform3D transform,
double[] q)
Extract the rotation part of a similarity transform stored in a AffineTransform3D.
Parameters:
transform - assumed to be a similarity transform (isotropic scaling + rotation + translation).
q - rotation will be stored as a quaternion here.
• #### extractRotationAnisotropic

public static void extractRotationAnisotropic(AffineTransform3D transform,
double[] q)
Extract the rotation from an AffineTransform3D comprising anisotropic scaling, rotation, and translation.
Parameters:
transform - assumed to comprise anisotropic scaling, followed by rotation and translation.
q - rotation will be stored as a quaternion here.
• #### extractApproximateRotationAffine

public static void extractApproximateRotationAffine(AffineTransform3D transform,
double[] q,
int coerceAffineDimension)
Extract a rotation from a general AffineTransform3D. Because the affine can comprise shearing which is not purely due to anisotropic scaling, there is no unique rotation to extract. The rotation is computed in the following way: The (X, Y, Z) unit axis are transformed and scaled to unit length. The resulting transformed unit vectors (X', Y', Z') are not necessarily pairwise orthogonal. We find unit vectors (X'', Y'', Z'') to form an orthogonal basis as follows: The axis specified by the coerceAffineDimension parameter is computed to be orthogonal to the remaining two. Assuming coerceAffineDimension=2, we would set Z'' = X' x Y' . The next axis (right handed axis order) after the coerced one is maintained, in this case X'' = X'. Finally the last axis is made perpendicular, Y'' = Z'' x X''. The rotation that takes (X, Y, Z) to (X'', Y'', Z'') is returned. The effect is that the plane spanned by the two non-coerced axes (if coerceAffineDimension=2, the XY plane) will be transformed to the same plane by the computed rotation and the "rotation part" of transform.
Parameters:
transform - assumed to comprise anisotropic scaling, followed by rotation and translation.
q - rotation will be stored as a quaternion here.
coerceAffineDimension - the plane spanned by the remaining two axes (if coerceAffineDimension=2, the XY plane) will be transformed to the same plane by the computed rotation and the "rotation part" of transform.
• #### extractScale

public static double extractScale(AffineTransform3D transform,
int axis)
Get the scale factor along the X, Y, or Z axis. For example, a points A=(x,0,0) and B=(x+1,0,0) on the X axis will be transformed to points A'=T*A and B'=T*B by the transform T. The distance between A' and B' gives the X scale factor.
Parameters:
transform - an affine transform.
axis - index of the axis for which the scale factor should be computed.
Returns:
scale factor.
• #### toString

public static final String toString(AffineTransform3D transform)
Pretty-print the matrix content of an affine transform.
Parameters:
transform - the transform to print.
Returns:
a string representation of the specified transform.