Class TransMatrixd
- java.lang.Object
-
- WildMagic.LibFoundation.Mathematics.Matrix4d
-
- gov.nih.mipav.model.structures.TransMatrixd
-
- All Implemented Interfaces:
java.io.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEGREES
used for setting rotationprivate boolean
m_Is2D
Transform was constructed to transform 2D vectors, instead of 3Dprivate boolean
m_IsNIFTI
boolean indicating whether this matrix is associated with a NIFTI image (special case handling)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 matrixprivate int
m_TransformID
Transform ID associated with the matrix.static int
RADIANS
used for setting rotationstatic int
TRANSFORM_ANOTHER_DATASET
Another Dataset transform ID.static int
TRANSFORM_COMPOSITE
Composite, dynamically generated matrix typeprivate static java.lang.String[]
TRANSFORM_ID_STR
Array of transform ID strings.static int
TRANSFORM_MNI_152
MNI 152 transform ID.static int
TRANSFORM_NIFTI_SCANNER_ANATOMICAL
Scanner anatomical matrix associated with NIFTI typestatic int
TRANSFORM_SCANNER_ANATOMICAL
Scanner Anatomical transform ID.static int
TRANSFORM_TALAIRACH_TOURNOUX
Talairach Tournoux transform ID.static int
TRANSFORM_UNKNOWN
Composite transform ID.
-
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)
TransMatrixd(TransMatrixd rkTM)
copy constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TransMatrixd
clone()
void
Copy(TransMatrixd rkTM)
copy, overwrite this.void
copyMatrix(double[][] newMatrix)
Copies provided transformation matrix.private void
decodeLine(java.io.RandomAccessFile raFile, int row, WildMagic.LibFoundation.Mathematics.Matrix4d matrix)
Decodes the line in the matrix file.void
decodeMatrixString(java.lang.String str)
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 arrayint
getDim()
Return dimension passed to constructor.int
getID()
int
getTransformID()
Returns the transform ID associated with the matrix.static int
getTransformIDFromStr(java.lang.String s)
Returns the transform ID associated with a string.static java.lang.String[]
getTransformIDStr()
Return the list of transform ID strings (for edit attributes combo box.static java.lang.String
getTransformIDStr(int m)
Return the string associated with the matrix transform ID.void
Inverse()
Matrix inversion that replaces this objects matrix with an inverted matrix.boolean
isIdentity()
Reports whether transform is Identity transform, to within a small epsilon.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 MatrixHolderboolean
isQform()
Tells whether a NIFTI matrix is a qform matrix or a sform matrixjava.lang.String
matrixToString(int w, int d)
Produces a string of the matrix values.void
readMatrix(java.io.RandomAccessFile raFile, boolean composite)
Reads transformation matrix to a text file.void
saveMatrix(java.io.RandomAccessFile raFile)
Saves transformation matrix to a text file MIPAV formatvoid
saveMatrix(java.io.RandomAccessFile raFile, java.lang.String message)
Saves transformation matrix to a text file MIPAV formatvoid
saveMatrix(java.lang.String fileName)
Saves transformation matrix to a text file MIPAV formatvoid
saveMatrix(java.lang.String fileName, java.lang.String message)
Saves transformation matrix to a text file MIPAV formatvoid
saveXFMMatrix(java.io.RandomAccessFile raFile)
Saves transformation matrix to McGill XFM formatvoid
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.java.lang.String
toDialogString()
Produces a string of the matrix values, rows separated by tabs.java.lang.String
toString()
ToString method that includes the matrix printout as well as the transform ID of the transmatrixdvoid
transform(double[] pt, double[] tPt)
Takes a 3D or 2D point (as a double array) and premultiplies it by the 3D transformation matrix.void
transform(double x, double y, double[] tPt)
Takes double components of a 2D point and premultiplies it by the 2d transformation matrix.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.void
transform(float[] pt, float[] tPt)
Takes a 3D point, as a float array, and premultiplies it by the 3D transformation matrix.void
transform(float x, float y, float[] tPt)
Takes float components of a 2D point and premultiplies it by the 2d transformation matrix.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.java.awt.Polygon
transform(java.awt.Polygon gon)
Tranforms a Polygon (2D).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.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.void
transformAsVector3Dd(VOIBase vects, WildMagic.LibFoundation.Mathematics.Vector3d[] tVects)
Takes an array of Vector3Dd 2D vectors and multiplies them with the 2d transformation matrix.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
-
-
-
-
Field Detail
-
TRANSFORM_UNKNOWN
public static final int TRANSFORM_UNKNOWN
Composite transform ID.- See Also:
- Constant Field Values
-
TRANSFORM_SCANNER_ANATOMICAL
public static final int TRANSFORM_SCANNER_ANATOMICAL
Scanner Anatomical transform ID.- See Also:
- Constant Field Values
-
TRANSFORM_ANOTHER_DATASET
public static final int TRANSFORM_ANOTHER_DATASET
Another Dataset transform ID.- See Also:
- Constant Field Values
-
TRANSFORM_TALAIRACH_TOURNOUX
public static final int TRANSFORM_TALAIRACH_TOURNOUX
Talairach Tournoux transform ID.- See Also:
- Constant Field Values
-
TRANSFORM_MNI_152
public static final int TRANSFORM_MNI_152
MNI 152 transform ID.- See Also:
- Constant Field Values
-
TRANSFORM_COMPOSITE
public static final int TRANSFORM_COMPOSITE
Composite, dynamically generated matrix type- See Also:
- Constant Field Values
-
TRANSFORM_NIFTI_SCANNER_ANATOMICAL
public static final int TRANSFORM_NIFTI_SCANNER_ANATOMICAL
Scanner anatomical matrix associated with NIFTI type- See Also:
- Constant Field Values
-
TRANSFORM_ID_STR
private static final java.lang.String[] TRANSFORM_ID_STR
Array of transform ID strings.
-
DEGREES
public static final int DEGREES
used for setting rotation- See Also:
- Constant Field Values
-
RADIANS
public static final int RADIANS
used for setting rotation- See Also:
- Constant Field Values
-
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 Detail
-
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 Detail
-
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 classjava.lang.Object
- Returns:
- deep copy of this.
-
Copy
public void Copy(TransMatrixd rkTM)
copy, overwrite this.- Parameters:
rkTM
- matrix to copy
-
decodeMatrixString
public void decodeMatrixString(java.lang.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 radianstrans
- translationscale
- scale, for each dimensionshear
- 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(java.io.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 pointercomposite
- 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(java.lang.String fileName)
Saves transformation matrix to a text file MIPAV format- Parameters:
fileName
- - file name, including the path- See Also:
saveMatrix(java.io.RandomAccessFile)
-
saveMatrix
public void saveMatrix(java.lang.String fileName, java.lang.String message)
Saves transformation matrix to a text file MIPAV format- Parameters:
fileName
- - file name, including the pathmessage
- String, may be null for no message.- See Also:
saveMatrix(java.io.RandomAccessFile,java.lang.String)
-
saveMatrix
public void saveMatrix(java.io.RandomAccessFile raFile)
Saves transformation matrix to a text file MIPAV format4 // 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(java.io.RandomAccessFile,java.lang.String)
-
saveMatrix
public void saveMatrix(java.io.RandomAccessFile raFile, java.lang.String message)
Saves transformation matrix to a text file MIPAV format4 // 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 pointermessage
- String, may be null for no message.
-
saveXFMMatrix
public void saveXFMMatrix(java.io.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 copycolumn
- 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 indexi1
- Final row indexj0
- Initial column indexj1
- Final column indexX
- A(i0:i1,j0:j1)- Throws:
java.lang.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:
java.lang.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
- row0beta
- row1gamma
- 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 skewy
- y skewz
- z skew
-
setTransform
public void setTransform(double tX, double tY, double r)
Sets 2D transformation matrix.- Parameters:
tX
- x translationtY
- y translationr
- 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 translationtY
- y translationtZ
- z translationrX
- x rotation angle in degreesrY
- y rotation angle in degreesrZ
- 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 translationtY
- y translationtZ
- z translationrX
- x rotation angle in degreesrY
- y rotation angle in degreesrZ
- z rotation angle in degreessX
- x scalesY
- y scalesZ
- z scaleskX
- x skewskY
- y skewskZ
- z skew
-
setTranslate
public void setTranslate(double x, double y)
Sets translation parts of 2D matrix.- Parameters:
x
- x translationy
- y translation
-
setTranslate
public void setTranslate(double x, double y, double z)
Sets the translation parts of 3D matrix (4D Homogenous).- Parameters:
x
- x translationy
- y translationz
- z translation
-
setZoom
public void setZoom(double sx, double sy)
Sets the zoom parts of 2D matrix.- Parameters:
sx
- zoom in the x coordinatesy
- 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 coordinatesy
- zoom in the y coordinatesz
- zoom in the z coordinate
-
toDialogString
public java.lang.String toDialogString()
Produces a string of the matrix values, rows separated by tabs.- Returns:
- formatted string
-
transform
public final java.awt.Polygon transform(java.awt.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 transformedtVects
- 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 transformedtVects
- 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 transformedtVects
- 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 transformedtPt
- 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 transformedtPt
- 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 transformedtPt
- 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 transformdy
- y coordinate to be transformdtPt
- 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 transformedy
- y coordinate to be transformedtPt
- 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 transformedy
- y coordinate to be transformedz
- z coordinate to be transformedtPt
- 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 transformedy
- y coordinate to be transformedz
- z coordinate to be transformedtPt
- 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(java.lang.String s)
Returns the transform ID associated with a string.- Parameters:
s
- String to test- Returns:
- data type
-
getTransformIDStr
public static java.lang.String[] getTransformIDStr()
Return the list of transform ID strings (for edit attributes combo box.- Returns:
- string [] of transform ID
-
getTransformIDStr
public static java.lang.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 java.lang.String toString()
ToString method that includes the matrix printout as well as the transform ID of the transmatrixd- Overrides:
toString
in classWildMagic.LibFoundation.Mathematics.Matrix4d
- Returns:
- printout
-
decodeLine
private void decodeLine(java.io.RandomAccessFile raFile, int row, WildMagic.LibFoundation.Mathematics.Matrix4d matrix)
Decodes the line in the matrix file.- Parameters:
raFile
- file pointerrow
- row reference to store transformation matrixmatrix
- 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 java.lang.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.
-
-