Class Matrix4
java.lang.Object
org.apache.sis.referencing.operation.matrix.MatrixSIS
org.apache.sis.referencing.operation.matrix.Matrix4
- All Implemented Interfaces:
Serializable
,Cloneable
,LenientComparable
,org.opengis.referencing.operation.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
- Version:
- 1.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptiondouble
The first matrix element in the first row.double
The second matrix element in the first row.double
The third matrix element in the first row.double
The forth matrix element in the first row.double
The first matrix element in the second row.double
The second matrix element in the second row.double
The third matrix element in the second row.double
The forth matrix element in the second row.double
The first matrix element in the third row.double
The second matrix element in the third row.double
The third matrix element in the third row.double
The forth matrix element in the third row.double
The first matrix element in the forth row.double
The second matrix element in the forth row.double
The third matrix element in the forth row.double
The forth matrix element in the forth row.private static final long
Serial number for inter-operability with different versions.static final int
The matrix size, which is 4. -
Constructor Summary
ConstructorsConstructorDescriptionMatrix4()
Creates a new identity matrix.Matrix4
(boolean ignore) Creates a new matrix filled with only zero values.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.Matrix4
(org.opengis.referencing.operation.Matrix matrix) Creates a new matrix initialized to the same value than the specified one. -
Method Summary
Modifier and TypeMethodDescriptionstatic Matrix4
castOrCopy
(org.opengis.referencing.operation.Matrix matrix) Casts or copies the given matrix to aMatrix4
implementation.clone()
Returns a clone of this matrix.final double
getElement
(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.(package private) final void
getElements
(double[] elements) Copies the matrix elements in the given flat array.final int
Returns the number of columns in this matrix, which is always 4 in this implementation.final int
Returns the number of rows in this matrix, which is always 4 in this implementation.final boolean
isAffine()
Returnstrue
if this matrix represents an affine transform.final boolean
Returnstrue
if this matrix is an identity matrix.final void
setElement
(int row, int column, double value) Modifies the value at the specified row and column of this matrix.final void
setElements
(double[] elements) Sets all matrix elements from a flat, row-major (column indices vary fastest) array.void
Sets the value of this matrix to its transpose.Methods inherited from class org.apache.sis.referencing.operation.matrix.MatrixSIS
convertAfter, convertBefore, ensureLengthMatch, ensureNumRowMatch, ensureSizeMatch, equals, equals, equals, get, getElements, getInteger, getNumber, hashCode, indexOutOfBounds, inverse, isAffine, isExtendedPrecision, multiply, multiply, normalizeColumns, removeColumns, removeRows, set, setElements, setMatrix, setNumber, solve, toString, translate
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
SIZE
public static final int SIZEThe matrix size, which is 4.- See Also:
-
m00
public double m00The first matrix element in the first row. -
m01
public double m01The second matrix element in the first row. -
m02
public double m02The third matrix element in the first row. -
m03
public double m03The forth matrix element in the first row. -
m10
public double m10The first matrix element in the second row. -
m11
public double m11The second matrix element in the second row. -
m12
public double m12The third matrix element in the second row. -
m13
public double m13The forth matrix element in the second row. -
m20
public double m20The first matrix element in the third row. -
m21
public double m21The second matrix element in the third row. -
m22
public double m22The third matrix element in the third row. -
m23
public double m23The forth matrix element in the third row. -
m30
public double m30The first matrix element in the forth row. -
m31
public double m31The second matrix element in the forth row. -
m32
public double m32The third matrix element in the forth row. -
m33
public double m33The forth matrix element in the forth row.
-
-
Constructor Details
-
Matrix4
public Matrix4()Creates a new identity matrix. -
Matrix4
Matrix4(boolean ignore) Creates a new matrix filled with only zero values.- Parameters:
ignore
- shall always befalse
in current version.
-
Matrix4
public 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.
-
Matrix4
Creates 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:
-
Matrix4
Matrix4(org.opengis.referencing.operation.Matrix matrix) throws IllegalArgumentException Creates a new matrix initialized to the same value than the specified one. The specified matrix size must be 4×4. This is not verified by this constructor, since it shall be verified byMatrices
.- Parameters:
matrix
- the matrix to copy.- Throws:
IllegalArgumentException
- if the given matrix is not of the expected size.
-
-
Method Details
-
castOrCopy
public static Matrix4 castOrCopy(org.opengis.referencing.operation.Matrix matrix) throws MismatchedMatrixSizeException Casts or copies the given matrix to aMatrix4
implementation. If the givenmatrix
is already an instance ofMatrix4
, then it is returned unchanged. Otherwise this method verifies the matrix size, then copies all elements in a newMatrix4
object.- Parameters:
matrix
- the matrix to cast or copy, ornull
.- Returns:
- the matrix argument if it can be safely casted (including
null
argument), or a copy of the given matrix otherwise. - Throws:
MismatchedMatrixSizeException
- if the size of the given matrix is not 4×4.
-
getNumRow
public final int getNumRow()Returns the number of rows in this matrix, which is always 4 in this implementation.- Returns:
- always 4.
-
getNumCol
public final int getNumCol()Returns the number of columns in this matrix, which is always 4 in this implementation.- Returns:
- always 4.
-
getElement
public 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
…m33
fields can be read directly for efficiency.- Specified by:
getElement
in interfaceorg.opengis.referencing.operation.Matrix
- Specified by:
getElement
in classMatrixSIS
- 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.
-
setElement
public final void setElement(int row, int column, double value) -
getElements
public final double[] getElements()Returns all matrix elements in a flat, row-major (column indices vary fastest) array. The array length is 16.- Overrides:
getElements
in classMatrixSIS
- Returns:
- a copy of all current matrix elements in a row-major array.
-
getElements
final void getElements(double[] elements) Copies the matrix elements in the given flat array. The array length shall be at least 16, may also be 32.- Overrides:
getElements
in classMatrixSIS
- Parameters:
elements
- the destination array. May be longer than necessary (this happen when the caller needs to appendDoubleDouble.error
values after the elements).
-
setElements
public 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:
setElements
in classMatrixSIS
- Parameters:
elements
- The new matrix elements in a row-major array.- See Also:
-
isAffine
public final boolean isAffine()Returnstrue
if 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. -
isIdentity
public final boolean isIdentity()Returnstrue
if this matrix is an identity matrix. This method is equivalent to the following code, except that it is potentially more efficient:- Specified by:
isIdentity
in interfaceorg.opengis.referencing.operation.Matrix
- Specified by:
isIdentity
in classMatrixSIS
- Returns:
true
if this matrix is an identity matrix.- See Also:
-
transpose
public void transpose()Sets the value of this matrix to its transpose. -
clone
Returns a clone of this matrix.
-