- java.lang.Object
-
- bdv.util.Affine3DHelpers
-
public class Affine3DHelpers extends Object
Helpers to extract parts (rotation, scale, etc) fromAffineTransform3D. Note that most of these helpers assume additional restrictions on the affine transform.- Author:
- Tobias Pietzsch
-
-
Constructor Summary
Constructors Constructor Description Affine3DHelpers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanequals(net.imglib2.realtransform.AffineTransform3D t1, net.imglib2.realtransform.AffineTransform3D t2)Compare two transforms for equality.static voidextractApproximateRotationAffine(net.imglib2.realtransform.AffineTransform3D transform, double[] q, int coerceAffineDimension)Extract a rotation from a generalAffineTransform3D.static voidextractRotation(net.imglib2.realtransform.AffineTransform3D transform, double[] q)Extract the rotation part of a similarity transform stored in aAffineTransform3D.static voidextractRotationAnisotropic(net.imglib2.realtransform.AffineTransform3D transform, double[] q)Extract the rotation from anAffineTransform3Dcomprising anisotropic scaling, rotation, and translation.static doubleextractScale(net.imglib2.realtransform.AffineTransform3D transform, int axis)Get the scale factor along the X, Y, or Z axis.static StringtoString(net.imglib2.realtransform.AffineTransform3D transform)Pretty-print the matrix content of an affine transform.
-
-
-
Method Detail
-
extractRotation
public static void extractRotation(net.imglib2.realtransform.AffineTransform3D transform, double[] q)
Extract the rotation part of a similarity transform stored in aAffineTransform3D.- 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(net.imglib2.realtransform.AffineTransform3D transform, double[] q)
Extract the rotation from anAffineTransform3Dcomprising 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(net.imglib2.realtransform.AffineTransform3D transform, double[] q, int coerceAffineDimension)
Extract a rotation from a generalAffineTransform3D. 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 thecoerceAffineDimensionparameter is computed to be orthogonal to the remaining two. AssumingcoerceAffineDimension=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 (ifcoerceAffineDimension=2, the XY plane) will be transformed to the same plane by the computed rotation and the "rotation part" oftransform.- 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 (ifcoerceAffineDimension=2, the XY plane) will be transformed to the same plane by the computed rotation and the "rotation part" oftransform.
-
extractScale
public static double extractScale(net.imglib2.realtransform.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.
-
equals
public static boolean equals(net.imglib2.realtransform.AffineTransform3D t1, net.imglib2.realtransform.AffineTransform3D t2)
Compare two transforms for equality.- Returns:
trueifft1andt2are exactly the same
-
toString
public static final String toString(net.imglib2.realtransform.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.
-
-