Class AffineTransform3D

java.lang.Object
org.jogamp.java3d.Transform3D
com.xinapse.geom3d.AffineTransform3D
All Implemented Interfaces:
Cloneable

public class AffineTransform3D extends org.jogamp.java3d.Transform3D implements Cloneable
The AffineTransform3D class represents a 3D affine transform that performs a linear mapping from 3D coordinates to other 3D coordinates that preserves the "straightness" and "parallelness" of lines. Affine transformations can be constructed using sequences of translations, scales, flips, rotations, and shears.

Such a coordinate transformation can be represented by a 4 row by 4 column matrix with an implied last row of [ 0 0 0 1 ]. This matrix transforms source coordinates (x, y, z) into destination coordinates (x', y', z') by considering them to be a column vector and multiplying the coordinate vector by the matrix according to the following process:

   [ x']   [  m00  m01  m02  m03  ] [ x ]   [ m00x + m01y + m02z + m03 ]
   [ y'] = [  m10  m11  m12  m13  ] [ y ] = [ m10x + m11y + m12z + m13 ]
   [ z'] = [  m20  m21  m22  m23  ] [ z ]   [ m20x + m21y + m22z + m23 ]
   [ 1 ]   [   0    0    0    1   ] [ 1 ]   [             1            ]
   
  • Field Summary

    Fields inherited from class org.jogamp.java3d.Transform3D

    AFFINE, CONGRUENT, IDENTITY, NEGATIVE_DETERMINANT, ORTHOGONAL, RIGID, SCALE, TRANSLATION, ZERO
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs and initializes a transform to the identity transform.
    AffineTransform3D(float[] matrix)
    Constructs and initializes a transform from the float array of length 12; the top row of the matrix is initialized to the first four elements of the array, and so on.
    AffineTransform3D(org.jogamp.java3d.Transform3D t1)
    Constructs and initializes a transform from the Transform3D object.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the AffineTransform3D that is the average of several AffineTransform3Ds.
    Creates and returns a copy of this AffineTransform3D.
    void
    get12(float[] matrix)
    Sets the matrix values of this transform to the matrix values in the single precision array parameter.
    float[]
    Returns a three rotation angles (the Euler angles) about the x, y and z axes from this AffineTransform3D.
    static void
    main(String[] args)
    Runs the self-test for AffineTransform3D.
    void
    set12(float[] matrix)
    Sets the matrix values of this transform to the matrix values in the single precision array parameter.
    Returns the approximate square root of this AffineTransform3D.
    Returns a String suitable for printing out this AffineTransform3D in a form suitable for later parsing.
    Returns a String that represents the value of this Object.
    void
    transform(float[] ptSrc, float[] ptDst)
    Transforms an array of (x,y,z) locations by this transform.
    float[]
    transform(int nX, int nY, int nZ, float pixelXSize, float pixelYSize, float pixelZSize, float[] dst)
    Transforms a set of points by this transform.
    void
    transform(org.jogamp.vecmath.Point3f[] ptSrc, int srcOff, org.jogamp.vecmath.Point3f[] ptDst, int dstOff, int numPts)
    Transforms an array of point objects by this transform.

    Methods inherited from class org.jogamp.java3d.Transform3D

    add, add, determinant, epsilonEquals, equals, equals, frustum, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, getAutoNormalize, getBestType, getDeterminantSign, getRotationScale, getRotationScale, getScale, getScale, getType, hashCode, invert, invert, lookAt, mul, mul, mul, mul, mulInverse, mulInverse, mulTransposeBoth, mulTransposeLeft, mulTransposeRight, normalize, normalize, normalizeCP, normalizeCP, ortho, perspective, rotX, rotY, rotZ, scaleAdd, scaleAdd, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, setAutoNormalize, setEuler, setIdentity, setNonUniformScale, setRotation, setRotation, setRotation, setRotation, setRotation, setRotation, setRotationScale, setRotationScale, setScale, setScale, setTranslation, setTranslation, setZero, sub, sub, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transpose, transpose

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AffineTransform3D

      public AffineTransform3D()
      Constructs and initializes a transform to the identity transform.
    • AffineTransform3D

      public AffineTransform3D(float[] matrix)
      Constructs and initializes a transform from the float array of length 12; the top row of the matrix is initialized to the first four elements of the array, and so on. The type of the transform object is classified internally.
      Parameters:
      matrix - a float array of length 12.
    • AffineTransform3D

      public AffineTransform3D(org.jogamp.java3d.Transform3D t1)
      Constructs and initializes a transform from the Transform3D object.
      Parameters:
      t1 - the transformation object to be copied.
  • Method Details

    • get12

      public void get12(float[] matrix)
      Sets the matrix values of this transform to the matrix values in the single precision array parameter. The matrix type is classified internally by the AffineTransform3D class.
      Parameters:
      matrix - the single precision array of length 12 in row major format.
    • set12

      public void set12(float[] matrix)
      Sets the matrix values of this transform to the matrix values in the single precision array parameter. The matrix type is classified internally by the AffineTransform3D class.
      Parameters:
      matrix - the single precision array of length 12 in row major format.
    • transform

      public void transform(org.jogamp.vecmath.Point3f[] ptSrc, int srcOff, org.jogamp.vecmath.Point3f[] ptDst, int dstOff, int numPts)
      Transforms an array of point objects by this transform. If any element of the ptDst array is null, a new Point3f object is allocated and stored into that element before storing the results of the transformation.

      Note that this method does not take any precautions to avoid problems caused by storing results into Point3f objects that will be used as the source for calculations further down the source array. This method does guarantee that if a specified Point3f object is both the source and destination for the same single point transform operation then the results will not be stored until the calculations are complete to avoid storing the results on top of the operands. If, however, the destination Point3f object for one operation is the same object as the source Point3f object for another operation further down the source array then the original coordinates in that point are overwritten before they can be converted.

      Parameters:
      ptSrc - the array containing the source point objects
      ptDst - the array into which the transform point objects are returned.
      srcOff - the offset to the first point object to be transformed in the source array.
      dstOff - the offset to the location of the first transformed point object that is stored in the destination array.
      numPts - the number of point objects to be transformed.
    • transform

      public void transform(float[] ptSrc, float[] ptDst)
      Transforms an array of (x,y,z) locations by this transform.

      Note that this method does not take any precautions to avoid problems caused by storing results that will be used as the source for calculations further down the source array. This method does guarantee that if a specified array is is both the source and destination for the same single point transform operation then the results will not be stored until the calculations are complete to avoid storing the results on top of the operands. If, however, the destination for one operation is the same object as the source for another operation further down the source array then the original coordinates in that point are overwritten before they can be converted.

      Parameters:
      ptSrc - the array containing the points in order x,y,z for point 1; x,y,z for point 2 etc.
      ptDst - the array into which the transformed points are returned.
    • transform

      public float[] transform(int nX, int nY, int nZ, float pixelXSize, float pixelYSize, float pixelZSize, float[] dst)
      Transforms a set of points by this transform. The points are in a 3-D grid, centered at the origin.
      Parameters:
      nX - the number of points in the x-direction.
      nY - the number of points in the y-direction.
      nZ - the number of points in the z-direction.
      pixelXSize - the spatial separation between points in the x-direction.
      pixelYSize - the spatial separation between points in the y-direction.
      pixelZSize - the spatial separation between points in the z-direction.
      dst - an array large enough to hold the x, y and z coordinates of the transformed points (i.e., nX * nY * nZ * 3). If dst is null, a new array is created.
      Returns:
      the dst array, if the one supplied was non-null, or the array created within this method.
    • toString

      public String toString()
      Returns a String that represents the value of this Object.
      Overrides:
      toString in class org.jogamp.java3d.Transform3D
      Returns:
      a String representing the value of this AffineTransform3D.
    • toPrintString

      public String toPrintString()
      Returns a String suitable for printing out this AffineTransform3D in a form suitable for later parsing.
      Returns:
      a String detailing this AffineTransform3D in a form suitable for later parsing.
    • clone

      public AffineTransform3D clone()
      Creates and returns a copy of this AffineTransform3D.
      Overrides:
      clone in class Object
      Returns:
      a copy of this AffineTransform3D.
    • average

      public static AffineTransform3D average(List<AffineTransform3D> transforms) throws IllegalArgumentException
      Returns the AffineTransform3D that is the average of several AffineTransform3Ds. The AffineTransform3Ds in the supplied List should not have any shear and scaling components. If they do, the average AffineTransform3D returned will not have any of these characteristics.
      Parameters:
      transforms - the List of transforms to average.
      Returns:
      an AffineTransform3D that is the average of the array of transforms.
      Throws:
      IllegalArgumentException - if the supplied list of transforms is empty.
    • sqrt

      public AffineTransform3D sqrt()
      Returns the approximate square root of this AffineTransform3D.
      Returns:
      a new AffineTransform3D that is the approximate square root of this.
    • getEulerAngles

      public float[] getEulerAngles()
      Returns a three rotation angles (the Euler angles) about the x, y and z axes from this AffineTransform3D.

      Note that the three angles returned are not the unique angles, just one possibility.

      Returns:
      the three Euler angles) about the x, y and z axes respectively.
    • main

      public static void main(String[] args)
      Runs the self-test for AffineTransform3D.
      Parameters:
      args - ignored.