Class TransMatrixd

java.lang.Object
WildMagic.LibFoundation.Mathematics.Matrix4d
gov.nih.mipav.model.structures.TransMatrixd
All Implemented Interfaces:
Serializable

public class TransMatrixd extends WildMagic.LibFoundation.Mathematics.Matrix4d
Transformation matrix class is an affine homogeneous class that can be used to rotate objects like images and VOIs. It can constructed as a 2D(3x3) or 3D(4x4) homogeneous matrix for transform (rotation, translation, skew and zoom) images/VOIs. Skew is not commonly used.

The MIPAV 3D model for 4 X 4 transformations is:

         [ m00 m01 m02 m03 ]   [ x ]   [ x' ]
         [ m10 m11 m12 m13 ] . [ y ] = [ y' ]
         [ m20 m21 m22 m23 ]   [ z ]   [ z' ]
         [ m30 m31 m32 m33 ]   [ w ]   [ w' ]
 
         x' = m00*x + m01*y + m02*z + m03*w
         y' = m10*x + m11*y + m12*z + m13*w
         z' = m20*x + m21*y + m22*z + m23*w
         w' = m30*x + m31*y + m32*z + m33*w
 

However, because the transform type is limited, we can always set the third row to [ 0 0 0 1] and write instead:

         [ m00 m01 m02 ]   [ x ]   [ t0 ]   [ x' ]
         [ m10 m11 m12 ] . [ y ] + [ t1 ] = [ y' ]
         [ m20 m21 m22 ]   [ z ]   [ t2 ]   [ z' ]
 
         x' = m00*x + m01*y + m02*z + t0
         y' = m10*x + m11*y + m12*z + t1
         z' = m20*x + m21*y + m22*z + t2
 

We still represent 4x4 m with a WildMagic Matrix4d, because of the existing implementations that assume a 4x4 matrix, and the use of the upper 3x3 matrix as a 2D transform.

We considered representing m with a WildMagic Matrix3d, and t with a Vector3d, as encapsulated in the WildMagic Transformation class, but it does not match typical Mipav usage.

ORDER OF TRANSFORMATIONS = TRANSLATE, ROTATE, ZOOM or TRANSLATE, ROTATE, SKEW, ZOOM
Row, Col format - right hand rule
2D Example

          zoom_x    theta    tx
          theta     zoom_y   ty
          0         0         1
 represented in 3D by leaving Z the identity transform:
          zoom_x    theta    0    tx
          theta     zoom_y   0    ty
          0         0        1    0
          0         0        0    1

 

Note that for 2D, the tx and ty components are stored in M02 and M12, and not in M03 and M13, as might be guessed by the use of a Matrix4d to store both 2D and 3D transforms.

Note for 3D - ref. Foley, Van Dam p. 214

          Axis of rotation            Direction of positive rotation is
              x                               y to z
              y                               z to x
              z                               x to y
 
          Order of rotation is important (i.e. not commutative)
          Rx Ry Ry != Ry Rx Rz
 
 
 
Version:
2, July 24, 2008, original 0.1 Nov 15, 1997
Author:
Matthew J. McAuliffe, Ph.D., changes Aron Helser, Geometric Tools
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    used for setting rotation
    private boolean
    Transform was constructed to transform 2D vectors, instead of 3D
    private boolean
    boolean indicating whether this matrix is associated with a NIFTI image (special case handling)
    private boolean
    If true, nifti matrix codes for a qform matrix If false, nifti matrix codes for a sform matrix Value has no effect if not a nifti matrix
    private int
    Transform ID associated with the matrix.
    static final int
    used for setting rotation
    static final int
    Another Dataset transform ID.
    static final int
    Composite, dynamically generated matrix type
    private static final String[]
    Array of transform ID strings.
    static final int
    MNI 152 transform ID.
    static final int
    Scanner anatomical matrix associated with NIFTI type
    static final int
    Scanner Anatomical transform ID.
    static final int
    Talairach Tournoux transform ID.
    static final int
    Composite transform ID.

    Fields inherited from class WildMagic.LibFoundation.Mathematics.Matrix4d

    IDENTITY, M00, M01, M02, M03, M10, M11, M12, M13, M20, M21, M22, M23, M30, M31, M32, M33, ZERO
  • Constructor Summary

    Constructors
    Constructor
    Description
    TransMatrixd(int dim)
    Construct a transformation matrix.
    TransMatrixd(int dim, int id)
     
    TransMatrixd(int dim, int id, boolean is_nifti, boolean isQform)
     
    copy constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    void
    copy, overwrite this.
    void
    copyMatrix(double[][] newMatrix)
    Copies provided transformation matrix.
    private void
    decodeLine(RandomAccessFile raFile, int row, WildMagic.LibFoundation.Mathematics.Matrix4d matrix)
    Decodes the line in the matrix file.
    void
    Decodes the matrix from a string into the matrix array.
    boolean
    decomposeMatrix(WildMagic.LibFoundation.Mathematics.Vector3d rotate, WildMagic.LibFoundation.Mathematics.Vector3d trans, WildMagic.LibFoundation.Mathematics.Vector3d scale, WildMagic.LibFoundation.Mathematics.Vector3d shear)
    Decomposing a matrix into simple transformations TransMatrixd transformation sequence: Scale(Sx, Sy, Sz)*ShearXY*ShearXZ*ShearYZ* RotateX*RotateY*RotateZ*Translate(tx, ty, tz) ( *Perspective(Px, Py, Pz, Pw), no longer supported)
    void
    getColumn(int r, double[] column)
    Copy our data into the provided double array
    int
    Return dimension passed to constructor.
    int
     
    final int
    Returns the transform ID associated with the matrix.
    static int
    Returns the transform ID associated with a string.
    static String[]
    Return the list of transform ID strings (for edit attributes combo box.
    static String
    Return the string associated with the matrix transform ID.
    void
    Matrix inversion that replaces this objects matrix with an inverted matrix.
    boolean
    Reports whether transform is Identity transform, to within a small epsilon.
    boolean
    Tells whether this matrix is associated with a NIFTI image this only matters when the matrix is being saved/when the composite matrix is being generated in MatrixHolder
    boolean
    Tells whether a NIFTI matrix is a qform matrix or a sform matrix
    matrixToString(int w, int d)
    Produces a string of the matrix values.
    void
    readMatrix(RandomAccessFile raFile, boolean composite)
    Reads transformation matrix to a text file.
    void
    Saves transformation matrix to a text file MIPAV format
    void
    Saves transformation matrix to a text file MIPAV format
    void
    saveMatrix(String fileName)
    Saves transformation matrix to a text file MIPAV format
    void
    saveMatrix(String fileName, String message)
    Saves transformation matrix to a text file MIPAV format
    void
    Saves transformation matrix to McGill XFM format
    void
    setIsNIFTI(boolean is_NIFTI)
    Accessor that sets whether or not the matrix is a NIFTI matrix.
    void
    setIsQform(boolean is_Qform)
    Accessor that sets whether a nifti matrix is a qform matrix or a sform matrix.
    void
    setMatrix(double[][] X)
    Set a submatrix.
    void
    setMatrix(int i0, int i1, int j0, int j1, double[][] X)
    Set a submatrix.
    void
    setRotate(double theta)
    Sets the rotation (2D) of transformation matrix.
    void
    setRotate(double thetaX, double thetaY, double thetaZ, int degreeORradian)
    Sets rotation (3D) of transformation matrix.
    void
    setRotate(WildMagic.LibFoundation.Mathematics.Vector3d alpha, WildMagic.LibFoundation.Mathematics.Vector3d beta, WildMagic.LibFoundation.Mathematics.Vector3d gamma)
    Sets rotation (3D) of transformation matrix.
    void
    setSkew(double x, double y)
    Sets skew part of 2D matrix.
    void
    setSkew(double x, double y, double z)
    Sets the skew parts of 3D matrix (4D Homogenous).
    void
    setTransform(double tX, double tY, double r)
    Sets 2D transformation matrix.
    void
    setTransform(double tX, double tY, double tZ, double rX, double rY, double rZ)
    Sets the 3D transformation matrix [4x4].
    void
    setTransform(double tX, double tY, double tZ, double rX, double rY, double rZ, double sX, double sY, double sZ, double skX, double skY, double skZ)
    Sets the 3D transformation matrix [4x4].
    void
    setTransformID(int t_id)
    Sets the transform ID for the matrix.
    void
    setTranslate(double x, double y)
    Sets translation parts of 2D matrix.
    void
    setTranslate(double x, double y, double z)
    Sets the translation parts of 3D matrix (4D Homogenous).
    void
    setZoom(double sx, double sy)
    Sets the zoom parts of 2D matrix.
    void
    setZoom(double sx, double sy, double sz)
    Sets the zoom parts of 3D matrix.
    Produces a string of the matrix values, rows separated by tabs.
    ToString method that includes the matrix printout as well as the transform ID of the transmatrixd
    final void
    transform(double[] pt, double[] tPt)
    Takes a 3D or 2D point (as a double array) and premultiplies it by the 3D transformation matrix.
    final void
    transform(double x, double y, double[] tPt)
    Takes double components of a 2D point and premultiplies it by the 2d transformation matrix.
    final void
    transform(double x, double y, double z, double[] tPt)
    Takes the double components of a 3D point and premultiplies it by the 3D transformation matrix.
    final void
    transform(float[] pt, float[] tPt)
    Takes a 3D point, as a float array, and premultiplies it by the 3D transformation matrix.
    final void
    transform(float x, float y, float[] tPt)
    Takes float components of a 2D point and premultiplies it by the 2d transformation matrix.
    final void
    transform(float x, float y, float z, float[] tPt)
    Takes the float components of a 3D point and premultiplies it by the 3D transformation matrix.
    final Polygon
    Tranforms a Polygon (2D).
    final void
    transformAsPoint2Dd(WildMagic.LibFoundation.Mathematics.Vector2d[] vects, WildMagic.LibFoundation.Mathematics.Vector2d[] tVects)
    Takes an array of Point2Dd 2D vectors and multiplies them with the 2d transformation matrix.
    final void
    transformAsPoint3Dd(WildMagic.LibFoundation.Mathematics.Vector3d pt, WildMagic.LibFoundation.Mathematics.Vector3d tPt)
    Takes a Point3Dd 3D point and multiplies it by the 3D transformation matrix.
    final void
    transformAsVector3Dd(VOIBase vects, WildMagic.LibFoundation.Mathematics.Vector3d[] tVects)
    Takes an array of Vector3Dd 2D vectors and multiplies them with the 2d transformation matrix.
    final void
    transformAsVector3Dd(WildMagic.LibFoundation.Mathematics.Vector3d[] vects, WildMagic.LibFoundation.Mathematics.Vector3d[] tVects)
    Takes an array of Vector3Dd 2D vectors and multiplies them with the 2d transformation matrix.

    Methods inherited from class WildMagic.LibFoundation.Mathematics.Matrix4d

    adjoint, copy, determinant, equals, get, getColumnMajor, getData, getData, identity, inverse, inverse, makeObliqueProjection, makePerspectiveProjection, makeReflection, makeZero, mult, mult, mult, mult, multLeft, multLeft, multLeft, multRight, multRight, qForm, set, set, timesTranspose, transpose, transpose, transposeTimes, transposeTimes

    Methods inherited from class java.lang.Object

    finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • TRANSFORM_UNKNOWN

      public static final int TRANSFORM_UNKNOWN
      Composite transform ID.
      See Also:
    • TRANSFORM_SCANNER_ANATOMICAL

      public static final int TRANSFORM_SCANNER_ANATOMICAL
      Scanner Anatomical transform ID.
      See Also:
    • TRANSFORM_ANOTHER_DATASET

      public static final int TRANSFORM_ANOTHER_DATASET
      Another Dataset transform ID.
      See Also:
    • TRANSFORM_TALAIRACH_TOURNOUX

      public static final int TRANSFORM_TALAIRACH_TOURNOUX
      Talairach Tournoux transform ID.
      See Also:
    • TRANSFORM_MNI_152

      public static final int TRANSFORM_MNI_152
      MNI 152 transform ID.
      See Also:
    • TRANSFORM_COMPOSITE

      public static final int TRANSFORM_COMPOSITE
      Composite, dynamically generated matrix type
      See Also:
    • TRANSFORM_NIFTI_SCANNER_ANATOMICAL

      public static final int TRANSFORM_NIFTI_SCANNER_ANATOMICAL
      Scanner anatomical matrix associated with NIFTI type
      See Also:
    • TRANSFORM_ID_STR

      private static final String[] TRANSFORM_ID_STR
      Array of transform ID strings.
    • DEGREES

      public static final int DEGREES
      used for setting rotation
      See Also:
    • RADIANS

      public static final int RADIANS
      used for setting rotation
      See Also:
    • m_TransformID

      private int m_TransformID
      Transform ID associated with the matrix.
    • m_IsNIFTI

      private boolean m_IsNIFTI
      boolean indicating whether this matrix is associated with a NIFTI image (special case handling)
    • m_IsQform

      private boolean m_IsQform
      If true, nifti matrix codes for a qform matrix If false, nifti matrix codes for a sform matrix Value has no effect if not a nifti matrix
    • m_Is2D

      private boolean m_Is2D
      Transform was constructed to transform 2D vectors, instead of 3D
  • Constructor Details

    • TransMatrixd

      public TransMatrixd(int dim)
      Construct a transformation matrix.
      Parameters:
      dim - should be 3 or 4 (square matrix)
    • TransMatrixd

      public TransMatrixd(int dim, int id)
    • TransMatrixd

      public TransMatrixd(int dim, int id, boolean is_nifti, boolean isQform)
    • TransMatrixd

      public TransMatrixd(TransMatrixd rkTM)
      copy constructor.
      Parameters:
      rkTM - matrix to copy
  • Method Details

    • getDim

      public int getDim()
      Return dimension passed to constructor.
      Returns:
      3 for 2D transform, 4 for 3D transform.
    • getID

      public int getID()
    • clone

      public TransMatrixd clone()
      Overrides:
      clone in class Object
      Returns:
      deep copy of this.
    • Copy

      public void Copy(TransMatrixd rkTM)
      copy, overwrite this.
      Parameters:
      rkTM - matrix to copy
    • decodeMatrixString

      public void decodeMatrixString(String str)
      Decodes the matrix from a string into the matrix array.
      Parameters:
      str - Matrix represented as a string.
    • decomposeMatrix

      public boolean decomposeMatrix(WildMagic.LibFoundation.Mathematics.Vector3d rotate, WildMagic.LibFoundation.Mathematics.Vector3d trans, WildMagic.LibFoundation.Mathematics.Vector3d scale, WildMagic.LibFoundation.Mathematics.Vector3d shear)
      Decomposing a matrix into simple transformations TransMatrixd transformation sequence: Scale(Sx, Sy, Sz)*ShearXY*ShearXZ*ShearYZ* RotateX*RotateY*RotateZ*Translate(tx, ty, tz) ( *Perspective(Px, Py, Pz, Pw), no longer supported)
      Parameters:
      rotate - rotation about x, y, z axis, in radians
      trans - translation
      scale - scale, for each dimension
      shear - shear.X is XY, shear.Y is XZ, shear.Z is YZ
      Returns:
      true if decompose was successful.
    • isIdentity

      public boolean isIdentity()
      Reports whether transform is Identity transform, to within a small epsilon.
      Returns:
      true iff identity
    • isNIFTI

      public boolean isNIFTI()
      Tells whether this matrix is associated with a NIFTI image this only matters when the matrix is being saved/when the composite matrix is being generated in MatrixHolder
      Returns:
      is this a nifti matrix
    • setIsNIFTI

      public void setIsNIFTI(boolean is_NIFTI)
      Accessor that sets whether or not the matrix is a NIFTI matrix.
      Parameters:
      is_NIFTI - val to set
    • isQform

      public boolean isQform()
      Tells whether a NIFTI matrix is a qform matrix or a sform matrix
      Returns:
      true if qform, false if sform.
    • setIsQform

      public void setIsQform(boolean is_Qform)
      Accessor that sets whether a nifti matrix is a qform matrix or a sform matrix.
      Parameters:
      is_Qform - val to set
    • readMatrix

      public void readMatrix(RandomAccessFile raFile, boolean composite)
      Reads transformation matrix to a text file.

      This method reads two formats MIPAV format

       4                    // number of rows in matrix 
       4                    // number of cols in matrix 
       0.234 0.33 0.22 5.0  // matrix info separated by a space 
       0.234 0.33 0.22 10.0 // matrix info separated by a space 
       0.234 0.33 0.22 12.0 // matrix info separated by a space 
       0.0 0.0 0.0 1.0      // matrix info separated by a space.
       
       

      Note the above is a homogenous transformation matrix

      FSL or alternate format supported

       0.234  0.33  0.22  5.0 // matrix info separated by 2 spaces 
       0.234  0.33  0.22  5.0 // matrix info separated by 2 spaces 
       0.234  0.33  0.22  5.0 // matrix info separated by 2 spaces
       0  0  0  1             // matrix info separated by 2 spaces
       

      also note integer values

      Parameters:
      raFile - random access file pointer
      composite - if true make a composite matrix of the by multipling this matrix with the one to be read from the file. If false replace this object matrix with a new matrix read from the file.
    • saveMatrix

      public void saveMatrix(String fileName)
      Saves transformation matrix to a text file MIPAV format
      Parameters:
      fileName - - file name, including the path
      See Also:
    • saveMatrix

      public void saveMatrix(String fileName, String message)
      Saves transformation matrix to a text file MIPAV format
      Parameters:
      fileName - - file name, including the path
      message - String, may be null for no message.
      See Also:
    • saveMatrix

      public void saveMatrix(RandomAccessFile raFile)
      Saves transformation matrix to a text file MIPAV format
       4                    // number of rows in matrix 
       4                    // number of cols in matrix 
       0.234 0.33 0.22 5.0  // matrix info separated by a space 
       0.234 0.33 0.22 10.0 // matrix info separated by a space 
       0.234 0.33 0.22 12.0 // matrix info separated by a space 
       0.0 0.0 0.0 1.0      // matrix info separated by a space.
       
      Parameters:
      raFile - random access file pointer
      See Also:
    • saveMatrix

      public void saveMatrix(RandomAccessFile raFile, String message)
      Saves transformation matrix to a text file MIPAV format
       4                    // number of rows in matrix 
       4                    // number of cols in matrix 
       0.234 0.33 0.22 5.0  // matrix info separated by a space 
       0.234 0.33 0.22 10.0 // matrix info separated by a space 
       0.234 0.33 0.22 12.0 // matrix info separated by a space 
       0.0 0.0 0.0 1.0      // matrix info separated by a space.
       
       
      Parameters:
      raFile - random access file pointer
      message - String, may be null for no message.
    • saveXFMMatrix

      public void saveXFMMatrix(RandomAccessFile raFile)
      Saves transformation matrix to McGill XFM format
      Parameters:
      raFile - random access file pointer
    • copyMatrix

      public void copyMatrix(double[][] newMatrix)
      Copies provided transformation matrix.
      Parameters:
      newMatrix - 2D array to copy, 3x3 or 4x4
    • getColumn

      public void getColumn(int r, double[] column)
      Copy our data into the provided double array
      Parameters:
      r - row to copy
      column - place to put column data, length 3 or 4
    • setMatrix

      public void setMatrix(int i0, int i1, int j0, int j1, double[][] X)
      Set a submatrix. Borrowed from Jama, useful for copying a Jama matrix M by passing in M.getArray() for param X
      Parameters:
      i0 - Initial row index
      i1 - Final row index
      j0 - Initial column index
      j1 - Final column index
      X - A(i0:i1,j0:j1)
      Throws:
      ArrayIndexOutOfBoundsException - Submatrix indices
    • setMatrix

      public void setMatrix(double[][] X)
      Set a submatrix. Borrowed from Jama, useful for copying a Jama matrix M by passing in M.getArray() for param X
      Parameters:
      X - A(i0:i1,j0:j1)
      Throws:
      ArrayIndexOutOfBoundsException - Submatrix indices
    • setRotate

      public void setRotate(double theta)
      Sets the rotation (2D) of transformation matrix.
      Parameters:
      theta - angle of rotation, in degrees
    • setRotate

      public void setRotate(WildMagic.LibFoundation.Mathematics.Vector3d alpha, WildMagic.LibFoundation.Mathematics.Vector3d beta, WildMagic.LibFoundation.Mathematics.Vector3d gamma)
      Sets rotation (3D) of transformation matrix.
      Parameters:
      alpha - row0
      beta - row1
      gamma - row2
    • setRotate

      public void setRotate(double thetaX, double thetaY, double thetaZ, int degreeORradian)
      Sets rotation (3D) of transformation matrix.
      Parameters:
      thetaX - angle (degrees or radians) of rotation about the X axis;
      thetaY - angle (degrees or radians) of rotation about the Y axis;
      thetaZ - angle (degrees or radians) of rotation about the Z axis;
      degreeORradian - DEGREES or RADIANS
    • setSkew

      public void setSkew(double x, double y)
      Sets skew part of 2D matrix.
      Parameters:
      x - Skew x parameter.
      y - Skew y parameter.
    • setSkew

      public void setSkew(double x, double y, double z)
      Sets the skew parts of 3D matrix (4D Homogenous).
      Parameters:
      x - x skew
      y - y skew
      z - z skew
    • setTransform

      public void setTransform(double tX, double tY, double r)
      Sets 2D transformation matrix.
      Parameters:
      tX - x translation
      tY - y translation
      r - rotation angle in degrees, about unseen z axis
    • setTransform

      public void setTransform(double tX, double tY, double tZ, double rX, double rY, double rZ)
      Sets the 3D transformation matrix [4x4].
      Parameters:
      tX - x translation
      tY - y translation
      tZ - z translation
      rX - x rotation angle in degrees
      rY - y rotation angle in degrees
      rZ - z rotation angle in degrees
    • setTransform

      public void setTransform(double tX, double tY, double tZ, double rX, double rY, double rZ, double sX, double sY, double sZ, double skX, double skY, double skZ)
      Sets the 3D transformation matrix [4x4].
      Parameters:
      tX - x translation
      tY - y translation
      tZ - z translation
      rX - x rotation angle in degrees
      rY - y rotation angle in degrees
      rZ - z rotation angle in degrees
      sX - x scale
      sY - y scale
      sZ - z scale
      skX - x skew
      skY - y skew
      skZ - z skew
    • setTranslate

      public void setTranslate(double x, double y)
      Sets translation parts of 2D matrix.
      Parameters:
      x - x translation
      y - y translation
    • setTranslate

      public void setTranslate(double x, double y, double z)
      Sets the translation parts of 3D matrix (4D Homogenous).
      Parameters:
      x - x translation
      y - y translation
      z - z translation
    • setZoom

      public void setZoom(double sx, double sy)
      Sets the zoom parts of 2D matrix.
      Parameters:
      sx - zoom in the x coordinate
      sy - zoom in the y coordinate
    • setZoom

      public void setZoom(double sx, double sy, double sz)
      Sets the zoom parts of 3D matrix.
      Parameters:
      sx - zoom in the x coordinate
      sy - zoom in the y coordinate
      sz - zoom in the z coordinate
    • toDialogString

      public String toDialogString()
      Produces a string of the matrix values, rows separated by tabs.
      Returns:
      formatted string
    • transform

      public final Polygon transform(Polygon gon)
      Tranforms a Polygon (2D).
      Parameters:
      gon - input polygon
      Returns:
      returns new transformed Polygon
    • transformAsPoint2Dd

      public final void transformAsPoint2Dd(WildMagic.LibFoundation.Mathematics.Vector2d[] vects, WildMagic.LibFoundation.Mathematics.Vector2d[] tVects)
      Takes an array of Point2Dd 2D vectors and multiplies them with the 2d transformation matrix.
      Parameters:
      vects - double vectors to be transformed
      tVects - transformed vectors
    • transformAsVector3Dd

      public final void transformAsVector3Dd(WildMagic.LibFoundation.Mathematics.Vector3d[] vects, WildMagic.LibFoundation.Mathematics.Vector3d[] tVects)
      Takes an array of Vector3Dd 2D vectors and multiplies them with the 2d transformation matrix.
      Parameters:
      vects - double vectors to be transformed
      tVects - transformed vectors
    • transformAsVector3Dd

      public final void transformAsVector3Dd(VOIBase vects, WildMagic.LibFoundation.Mathematics.Vector3d[] tVects)
      Takes an array of Vector3Dd 2D vectors and multiplies them with the 2d transformation matrix.
      Parameters:
      vects - double vectors to be transformed
      tVects - transformed vectors
    • transform

      public final void transform(double[] pt, double[] tPt)
      Takes a 3D or 2D point (as a double array) and premultiplies it by the 3D transformation matrix.
      Parameters:
      pt - coordinate to be transformed
      tPt - transformed point
    • transform

      public final void transform(float[] pt, float[] tPt)
      Takes a 3D point, as a float array, and premultiplies it by the 3D transformation matrix.
      Parameters:
      pt - coordinate to be transformed
      tPt - the transformed point
    • transformAsPoint3Dd

      public final void transformAsPoint3Dd(WildMagic.LibFoundation.Mathematics.Vector3d pt, WildMagic.LibFoundation.Mathematics.Vector3d tPt)
      Takes a Point3Dd 3D point and multiplies it by the 3D transformation matrix.
      Parameters:
      pt - 3D double point to be transformed
      tPt - transformed point
    • transform

      public final void transform(double x, double y, double[] tPt)
      Takes double components of a 2D point and premultiplies it by the 2d transformation matrix.
      Parameters:
      x - x coordinate to be transformd
      y - y coordinate to be transformd
      tPt - transformed point
    • transform

      public final void transform(float x, float y, float[] tPt)
      Takes float components of a 2D point and premultiplies it by the 2d transformation matrix.
      Parameters:
      x - x coordinate to be transformed
      y - y coordinate to be transformed
      tPt - transformed point
    • transform

      public final void transform(double x, double y, double z, double[] tPt)
      Takes the double components of a 3D point and premultiplies it by the 3D transformation matrix.
      Parameters:
      x - x coordinate to be transformed
      y - y coordinate to be transformed
      z - z coordinate to be transformed
      tPt - transformed point
    • transform

      public final void transform(float x, float y, float z, float[] tPt)
      Takes the float components of a 3D point and premultiplies it by the 3D transformation matrix.
      Parameters:
      x - x coordinate to be transformed
      y - y coordinate to be transformed
      z - z coordinate to be transformed
      tPt - the transformed point
    • getTransformID

      public final int getTransformID()
      Returns the transform ID associated with the matrix.
      Returns:
      int transform ID
    • getTransformIDFromStr

      public static int getTransformIDFromStr(String s)
      Returns the transform ID associated with a string.
      Parameters:
      s - String to test
      Returns:
      data type
    • getTransformIDStr

      public static String[] getTransformIDStr()
      Return the list of transform ID strings (for edit attributes combo box.
      Returns:
      string [] of transform ID
    • getTransformIDStr

      public static String getTransformIDStr(int m)
      Return the string associated with the matrix transform ID.
      Parameters:
      m - transform ID
      Returns:
      the string associated with the transform ID
    • setTransformID

      public void setTransformID(int t_id)
      Sets the transform ID for the matrix.
      Parameters:
      t_id - transform ID
    • toString

      public String toString()
      ToString method that includes the matrix printout as well as the transform ID of the transmatrixd
      Overrides:
      toString in class WildMagic.LibFoundation.Mathematics.Matrix4d
      Returns:
      printout
    • decodeLine

      private void decodeLine(RandomAccessFile raFile, int row, WildMagic.LibFoundation.Mathematics.Matrix4d matrix)
      Decodes the line in the matrix file.
      Parameters:
      raFile - file pointer
      row - row reference to store transformation matrix
      matrix - the matrix where the data is to be stored
    • Inverse

      public void Inverse()
      Matrix inversion that replaces this objects matrix with an inverted matrix. Special handling for 2D vs 3D cases.
    • matrixToString

      public String matrixToString(int w, int d)
      Produces a string of the matrix values.
      Parameters:
      w - Column width.
      d - Number of digits after the decimal.
      Returns:
      String containing the values from the matrix.