Class Matrix3
Object
Matrix3
- All Implemented Interfaces:
Serializable,Cloneable,Matrix,Cloneable,XMatrix
- Since:
- 2.2
- Author:
- Martin Desruisseaux (IRD)
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMatrix3()Creates a new identity matrix.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.Matrix3(AffineTransform transform) Constructs a 3×3 matrix from the specified affine transform.Creates a new matrix initialized to the same value than the specified one. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(double scalar) Performs an in-place scalar addition.voidSet to the scalar addition ofscalar+matrixvoidSet to the matrix addition ofthis+matrix.voidSet to the matrix addition ofmatrix1+matrix2.clone()Returns a clone of this matrix.doubleComputes the determinantbooleanbooleanCompares the element values.booleanequalsAffine(AffineTransform transform) Returnstrueif this matrix is equals to the specified affine transform.voidgetColumn(int col, double[] array) Extract col to provided array.doublegetElement(int row, int column) Returns the value at the row, column position in the matrix.final intReturns the number of colmuns 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.voidgetRow(int row, double[] array) Extract row to provided arrayinthashCode()voidinvert()Inverts this matrix in place.voidSet to the inverse of the provided matrix.final booleanisAffine()Returnstrueif this matrix is an affine transform.final booleanReturnstrueif this matrix is an identity matrix.final booleanisIdentity(double tolerance) Returnstrueif this matrix is an identity matrix using the provided tolerance.final booleanisNaN()Returnstrueif at least one value isNaN.voidmul(double scalar) Sets this matrix to the result of multiplying itself with the provided scalar.voidSets the value of this matrix to the result of multiplying the provided scalar and matrix.final voidIn-place multiply with provided matrix.voidIn-place update from matrix1 * matrix2.final voidSets the value of this matrix to the result of multiplying itself with the specified matrix.voidnegate()Changes the sign of each element in the matrix.voidNegates the value of this matrix:this = -matrix.voidset(double[] matrix) Update in place to the provided matrix (row-order).voidsetColumn(int column, double... values) Sets the value of the column using an array of values.voidsetElement(int row, int column, double value) Sets the value of the row, column position in the matrix.voidSets the main diagonal of this matrix to be 1.0.voidsetMatrix(AffineTransform transform) Sets this matrix to the specified affine transform.voidsetRow(int row, double... values) Sets the value of the row using an array of values.voidsetZero()Sets each value of the matrix to 0.0.voidsub(double scalar) In-place matrix subtraction:this - scalar.voidSet to the difference ofscalar - matrix2.voidIn-place matrix subtraction:this - matrix.voidSet to the difference ofmatrix1 - matrix2.final AffineTransformReturns an affine transform for this matrix.toString()Returns a string representation of this matrix.voidTransposes the matrix.voidSet to the transpose of the provided matrix.
-
Field Details
-
SIZE
public static final int SIZEThe matrix size, which is 3.- See Also:
-
-
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. -
Matrix3
Constructs a 3×3 matrix from the specified affine transform. -
Matrix3
-
-
Method Details
-
getNumRow
public final int getNumRow()Returns the number of rows in this matrix, which is always 3 in this implementation. -
getNumCol
public final int getNumCol()Returns the number of colmuns in this matrix, which is always 3 in this implementation. -
isNaN
public final boolean isNaN()Returnstrueif at least one value isNaN.- Since:
- 2.3
-
setMatrix
Sets this matrix to the specified affine transform.- Since:
- 2.3
-
equalsAffine
Returnstrueif this matrix is equals to the specified affine transform.- Since:
- 2.3
-
clone
Returns a clone of this matrix. -
isAffine
public final boolean isAffine()Returnstrueif this matrix is an affine transform. A transform is affine if the matrix is square and last row contains only zeros, except in the last column which contains 1. -
negate
public void negate()Changes the sign of each element in the matrix. -
negate
Description copied from interface:XMatrixNegates the value of this matrix:this = -matrix. -
transpose
public void transpose()Transposes the matrix. -
transpose
Description copied from interface:XMatrixSet to the transpose of the provided matrix. -
invert
public void invert()Description copied from interface:XMatrixInverts this matrix in place. -
invert
Description copied from interface:XMatrixSet to the inverse of the provided matrix.- Specified by:
invertin interfaceXMatrix- Parameters:
matrix- The matrix that is to be inverted. Not modified.- Throws:
SingularMatrixException- if this matrix is not invertible.
-
getElement
public double getElement(int row, int column) Returns the value at the row, column position in the matrix.- Specified by:
getElementin interfaceMatrix- Specified by:
getElementin interfaceXMatrix- Parameters:
row- The row number to be retrieved (zero indexed).column- The column number to be retrieved (zero indexed).- Returns:
- Matrix value at the given row and column.
-
setColumn
public void setColumn(int column, double... values) Description copied from interface:XMatrixSets the value of the column using an array of values. -
setRow
public void setRow(int row, double... values) Description copied from interface:XMatrixSets the value of the row using an array of values. -
setElement
public void setElement(int row, int column, double value) Sets the value of the row, column position in the matrix.- Specified by:
setElementin interfaceMatrix- Parameters:
row- The row number to be retrieved (zero indexed).column- The column number to be retrieved (zero indexed).value- The new matrix element value.
-
setZero
public void setZero()Sets each value of the matrix to 0.0. -
setIdentity
public void setIdentity()Sets the main diagonal of this matrix to be 1.0.- Specified by:
setIdentityin interfaceXMatrix
-
isIdentity
public final boolean isIdentity()Returnstrueif this matrix is an identity matrix.- Specified by:
isIdentityin interfaceMatrix- Returns:
trueif this matrix is an identity matrix.
-
isIdentity
public final boolean isIdentity(double tolerance) Returnstrueif this matrix is an identity matrix using the provided tolerance. This method is equivalent to computing the difference between this matrix and an identity matrix of identical size, and returningtrueif and only if all differences are smaller than or equal totolerance.- Specified by:
isIdentityin interfaceXMatrix- Parameters:
tolerance- The tolerance value.- Returns:
trueif this matrix is close enough to the identity matrix given the tolerance value.- Since:
- 2.3.1
-
multiply
Sets the value of this matrix to the result of multiplying itself with the specified matrix. In other words, performsthis=this×matrix. In the context of coordinate transformations, this is equivalent toAffineTransform.concatenate: first transforms by the supplied transform and then transform the result by the original transform. -
hashCode
public int hashCode() -
equals
-
equals
Description copied from interface:XMatrixCompares the element values. -
toAffineTransform2D
Returns an affine transform for this matrix. This is a convenience method for interoperability with Java2D.- Returns:
- The affine transform for this matrix.
- Throws:
IllegalStateException- if this matrix is not 3×3, or if the last row is not[0 0 1].
-
toString
Returns a string representation of this matrix. The returned string is implementation dependent. It is usually provided for debugging purposes only. -
getColumn
public void getColumn(int col, double[] array) Extract col to provided array. -
mul
public void mul(double scalar) Description copied from interface:XMatrixSets this matrix to the result of multiplying itself with the provided scalar. -
mul
Description copied from interface:XMatrixSets the value of this matrix to the result of multiplying the provided scalar and matrix. -
getRow
public void getRow(int row, double[] array) Extract row to provided array -
mul
In-place multiply with provided matrix. -
mul
In-place update from matrix1 * matrix2. -
sub
public void sub(double scalar) Description copied from interface:XMatrixIn-place matrix subtraction:this - scalar. -
sub
Description copied from interface:XMatrixSet to the difference ofscalar - matrix2. -
sub
Description copied from interface:XMatrixIn-place matrix subtraction:this - matrix. -
sub
Description copied from interface:XMatrixSet to the difference ofmatrix1 - matrix2. -
set
public void set(double[] matrix) Update in place to the provided matrix (row-order). -
add
public void add(double scalar) Description copied from interface:XMatrixPerforms an in-place scalar addition. -
add
Description copied from interface:XMatrixSet to the scalar addition ofscalar+matrix -
add
Description copied from interface:XMatrixSet to the matrix addition ofthis+matrix. -
add
Description copied from interface:XMatrixSet to the matrix addition ofmatrix1+matrix2. -
determinate
public double determinate()Description copied from interface:XMatrixComputes the determinant- Specified by:
determinatein interfaceXMatrix
-