- All Implemented Interfaces:
Serializable,Cloneable,LenientComparable,Matrix
A matrix of fixed 3×3 size.
The matrix members are:
┌ ┐ │ m00 m01 m02 │ │ m10 m11 m12 │ │ m20 m21 m22 │ └ ┘
- Since:
- 0.4
- See Also:
-
Field Summary
FieldsModifier 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 first matrix element in the second row.doubleThe second matrix element in the second row.doubleThe third 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.static final intThe matrix size, which is 3. -
Constructor Summary
ConstructorsConstructorDescriptionMatrix3()Creates a new identity matrix.Matrix3(double[] elements) Creates a new matrix initialized to the specified values.Matrix3(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22) Creates a new matrix initialized to the specified values. -
Method Summary
Modifier and TypeMethodDescriptionstatic Matrix3castOrCopy(Matrix matrix) Casts or copies the given matrix to aMatrix3implementation.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 3 in this implementation.final intReturns the number of rows in this matrix, which is always 3 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 MatrixSIS
convertAfter, convertBefore, equals, equals, equals, getInteger, getNumber, hashCode, inverse, multiply, multiply, normalizeColumns, removeColumns, removeRows, setMatrix, setNumber, solve, toString, translate
-
Field Details
-
SIZE
public static final int SIZEThe matrix size, which is 3.- 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. -
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. -
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.
-
-
Constructor Details
-
Matrix3
public Matrix3()Creates a new identity matrix. -
Matrix3
public Matrix3(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22) 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.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.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.
-
Matrix3
Creates a new matrix initialized to the specified values. The length of the given array must be 9 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
-
castOrCopy
Casts or copies the given matrix to aMatrix3implementation. If the givenmatrixis already an instance ofMatrix3, then it is returned unchanged. Otherwise this method verifies the matrix size, then copies all elements in a newMatrix3object.- Parameters:
matrix- the matrix to cast or copy, ornull.- 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 3×3.
-
getNumRow
public final int getNumRow()Returns the number of rows in this matrix, which is always 3 in this implementation.- Returns:
- always 3.
-
getNumCol
public final int getNumCol()Returns the number of columns in this matrix, which is always 3 in this implementation.- Returns:
- always 3.
-
getElement
public final double getElement(int row, int 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 9.- Overrides:
getElementsin classMatrixSIS- Returns:
- a copy of all current matrix elements in a row-major array.
-
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 9.- Overrides:
setElementsin classMatrixSIS- Parameters:
elements- The new matrix elements in a row-major array.- See Also:
-
isAffine
public 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 classMatrixSIS- Returns:
trueif this matrix represents an affine transform.- See Also:
-
isIdentity
public 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 interfaceMatrix- Specified by:
isIdentityin classMatrixSIS- Returns:
trueif this matrix is an identity matrix.- See Also:
-
transpose
public void transpose()Sets the value of this matrix to its transpose.- Specified by:
transposein classMatrixSIS
-
clone
Returns a clone of this matrix.- Specified by:
clonein interfaceMatrix- Overrides:
clonein classMatrixSIS- Returns:
- a new matrix of the same class and with the same values than this matrix.
- See Also:
-