Class Matrix4
- All Implemented Interfaces:
- Serializable,- Cloneable,- LenientComparable,- Matrix
A matrix of fixed 4×4 size, often used in datum shifts.
 The matrix members are:
 
┌ ┐ │ m00 m01 m02 m03 │ │ m10 m11 m12 m13 │ │ m20 m21 m22 m23 │ │ m30 m31 m32 m33 │ └ ┘
- Since:
- 0.4
- See Also:
Defined in the sis-referencing module
- 
Field SummaryFieldsModifier and TypeFieldDescriptiondoubleThe first matrix element in the first row.doubleThe second matrix element in the first row.doubleThe third matrix element in the first row.doubleThe forth matrix element in the first row.doubleThe first matrix element in the second row.doubleThe second matrix element in the second row.doubleThe third matrix element in the second row.doubleThe forth matrix element in the second row.doubleThe first matrix element in the third row.doubleThe second matrix element in the third row.doubleThe third matrix element in the third row.doubleThe forth matrix element in the third row.doubleThe first matrix element in the forth row.doubleThe second matrix element in the forth row.doubleThe third matrix element in the forth row.doubleThe forth matrix element in the forth row.static final intThe matrix size, which is 4.
- 
Constructor SummaryConstructorsConstructorDescriptionMatrix4()Creates a new identity matrix.Matrix4(double[] elements) Creates a new matrix initialized to the specified values.Matrix4(double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33) Creates a new matrix initialized to the specified values.
- 
Method SummaryModifier and TypeMethodDescriptionstatic Matrix4castOrCopy(Matrix matrix) Casts or copies the given matrix to aMatrix4implementation.clone()Returns a clone of this matrix.final doublegetElement(int row, int column) Retrieves the value at the specified row and column of this matrix.final double[]Returns all matrix elements in a flat, row-major (column indices vary fastest) array.final intReturns the number of columns in this matrix, which is always 4 in this implementation.final intReturns the number of rows in this matrix, which is always 4 in this implementation.final booleanReturnstrueif this matrix represents an affine transform.final booleanReturnstrueif this matrix is an identity matrix.final voidsetElement(int row, int column, double value) Modifies the value at the specified row and column of this matrix.final voidsetElements(double[] elements) Sets all matrix elements from a flat, row-major (column indices vary fastest) array.voidSets the value of this matrix to its transpose.Methods inherited from class MatrixSISconvertAfter, convertBefore, equals, equals, equals, getInteger, getNumber, hashCode, inverse, multiply, multiply, normalizeColumns, removeColumns, removeRows, setMatrix, setNumber, solve, toString, translate
- 
Field Details- 
SIZEpublic static final int SIZEThe matrix size, which is 4.- See Also:
 
- 
m00public double m00The first matrix element in the first row.
- 
m01public double m01The second matrix element in the first row.
- 
m02public double m02The third matrix element in the first row.
- 
m03public double m03The forth matrix element in the first row.
- 
m10public double m10The first matrix element in the second row.
- 
m11public double m11The second matrix element in the second row.
- 
m12public double m12The third matrix element in the second row.
- 
m13public double m13The forth matrix element in the second row.
- 
m20public double m20The first matrix element in the third row.
- 
m21public double m21The second matrix element in the third row.
- 
m22public double m22The third matrix element in the third row.
- 
m23public double m23The forth matrix element in the third row.
- 
m30public double m30The first matrix element in the forth row.
- 
m31public double m31The second matrix element in the forth row.
- 
m32public double m32The third matrix element in the forth row.
- 
m33public double m33The forth matrix element in the forth row.
 
- 
- 
Constructor Details- 
Matrix4public Matrix4()Creates a new identity matrix.
- 
Matrix4public Matrix4(double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33) Creates a new matrix initialized to the specified values.- Parameters:
- m00- the first matrix element in the first row.
- m01- the second matrix element in the first row.
- m02- the third matrix element in the first row.
- m03- the forth matrix element in the first row.
- m10- the first matrix element in the second row.
- m11- the second matrix element in the second row.
- m12- the third matrix element in the second row.
- m13- the forth matrix element in the second row.
- m20- the first matrix element in the third row.
- m21- the second matrix element in the third row.
- m22- the third matrix element in the third row.
- m23- the forth matrix element in the third row.
- m30- the first matrix element in the forth row.
- m31- the second matrix element in the forth row.
- m32- the third matrix element in the forth row.
- m33- the forth matrix element in the forth row.
 
- 
Matrix4Creates a new matrix initialized to the specified values. The length of the given array must be 16 and the values in the same order than the above constructor.- Parameters:
- elements- elements of the matrix. Column indices vary fastest.
- Throws:
- IllegalArgumentException- if the given array does not have the expected length.
- See Also:
 
 
- 
- 
Method Details- 
castOrCopyCasts or copies the given matrix to aMatrix4implementation. If the givenmatrixis already an instance ofMatrix4, then it is returned unchanged. Otherwise this method verifies the matrix size, then copies all elements in a newMatrix4object.- Parameters:
- matrix- the matrix to cast or copy, or- null.
- Returns:
- the matrix argument if it can be safely casted (including nullargument), or a copy of the given matrix otherwise.
- Throws:
- MismatchedMatrixSizeException- if the size of the given matrix is not 4×4.
 
- 
getNumRowpublic final int getNumRow()Returns the number of rows in this matrix, which is always 4 in this implementation.- Returns:
- always 4.
 
- 
getNumColpublic final int getNumCol()Returns the number of columns in this matrix, which is always 4 in this implementation.- Returns:
- always 4.
 
- 
getElementpublic final double getElement(int row, int column) Retrieves the value at the specified row and column of this matrix. This method can be invoked when the matrix size or type is unknown. If the matrix is known to be an instance ofMatrix4, then them00…m33fields can be read directly for efficiency.- Specified by:
- getElementin interface- Matrix
- Specified by:
- getElementin class- MatrixSIS
- Parameters:
- row- the row index, from 0 inclusive to 4 exclusive.
- column- the column index, from 0 inclusive to 4 exclusive.
- Returns:
- the current value at the given row and column.
 
- 
setElementpublic final void setElement(int row, int column, double value) 
- 
getElementspublic final double[] getElements()Returns all matrix elements in a flat, row-major (column indices vary fastest) array. The array length is 16.- Overrides:
- getElementsin class- MatrixSIS
- Returns:
- a copy of all current matrix elements in a row-major array.
 
- 
setElementspublic final void setElements(double[] elements) Sets all matrix elements from a flat, row-major (column indices vary fastest) array. The array length shall be 16.- Specified by:
- setElementsin class- MatrixSIS
- Parameters:
- elements- The new matrix elements in a row-major array.
- See Also:
 
- 
isAffinepublic final boolean isAffine()Returnstrueif this matrix represents an affine transform. A transform is affine if the matrix is square and its last row contains only zeros, except in the last column which contains 1.- Overrides:
- isAffinein class- MatrixSIS
- Returns:
- trueif this matrix represents an affine transform.
- See Also:
 
- 
isIdentitypublic final boolean isIdentity()Returnstrueif this matrix is an identity matrix. This method is equivalent to the following code, except that it is potentially more efficient:return Matrices.isIdentity(this, 0.0); - Specified by:
- isIdentityin interface- Matrix
- Specified by:
- isIdentityin class- MatrixSIS
- Returns:
- trueif this matrix is an identity matrix.
- See Also:
 
- 
transposepublic void transpose()Sets the value of this matrix to its transpose.- Specified by:
- transposein class- MatrixSIS
 
- 
cloneReturns a clone of this matrix.- Specified by:
- clonein interface- Matrix
- Overrides:
- clonein class- MatrixSIS
- Returns:
- a new matrix of the same class and with the same values than this matrix.
- See Also:
 
 
-