Class Matrix2
- Object
- 
- Matrix2
 
- 
- All Implemented Interfaces:
- Serializable,- Cloneable,- Matrix,- Cloneable,- XMatrix
 
 public class Matrix2 extends Object implements XMatrix, Serializable - Since:
- 2.2
- Author:
- Martin Desruisseaux (IRD)
- See Also:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description doublem00The first matrix element in the first row.doublem01The second matrix element in the first row.doublem10The first matrix element in the second row.doublem11The second matrix element in the second row.static intSIZEThe matrix size, which is 2.
 - 
Constructor SummaryConstructors Constructor Description Matrix2()Creates a new identity matrix.Matrix2(double m00, double m01, double m10, double m11)Creates a new matrix initialized to the specified values.Matrix2(Matrix matrix)Creates a new matrix initialized to the same value than the specified one.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(double scalar)Performs an in-place scalar addition.voidadd(double scalar, XMatrix matrix)Set to the scalar addition ofscalar+matrixvoidadd(XMatrix matrix)Set to the matrix addition ofthis+matrix.voidadd(XMatrix matrix1, XMatrix matrix2)Set to the matrix addition ofmatrix1+matrix2.Matrix2clone()Returns a clone of this matrix.doubledeterminate()Computes the determinantbooleanequals(Object object)Returnstrueif the specified object is of typeMatrix2and all of the data members are equal to the corresponding data members in this matrix.booleanequals(Matrix matrix, double tolerance)Compares the element values.voidgetColumn(int column, double[] array)Extract col to provided array.doublegetElement(int row, int col)Returns the element at the specified index.intgetNumCol()Returns the number of colmuns in this matrix, which is always 2 in this implementation.intgetNumRow()Returns the number of rows in this matrix, which is always 2 in this implementation.voidgetRow(int row, double[] array)Extract row to provided arrayinthashCode()Returns a hash code value based on the data values in this object.voidinvert()Inverts this matrix in place.voidinvert(Matrix matrix)Set to the inverse of the provided matrix.booleanisAffine()Returnstrueif this matrix is an affine transform.booleanisIdentity()Returnstrueif this matrix is an identity matrix.booleanisIdentity(double tolerance)Returnstrueif this matrix is an identity matrix using the provided tolerance.voidmul(double scalar)Sets this matrix to the result of multiplying itself with the provided scalar.voidmul(double scalar, Matrix matrix)Sets the value of this matrix to the result of multiplying the provided scalar and matrix.voidmul(Matrix matrix)Sets the value of this matrix to the result of multiplying itself with the specified matrix.voidmul(Matrix matrix1, Matrix matrix2)Sets the value of this matrix to the result of multiplying matrix1 and matrix2.voidmultiply(Matrix matrix)Sets the value of this matrix to the result of multiplying itself with the specified matrix.voidnegate()Negates the value of this matrix:this = -this.voidnegate(Matrix matrix)Negates the value of this matrix:this = -matrix.voidsetColumn(int column, double... values)Sets the value of the column using an array of values.voidsetElement(int row, int col, double value)Modifies the value at the specified row and column of this matrix.voidsetIdentity()Sets this matrix to the identity matrix.voidsetRow(int row, double... values)Sets the value of the row using an array of values.voidsetZero()Sets all the values in this matrix to zero.voidsub(double scalar)In-place matrix subtraction:this - scalar.voidsub(double scalar, Matrix matrix)Set to the difference ofscalar - matrix2.voidsub(Matrix matrix)In-place matrix subtraction:this - matrix.voidsub(Matrix matrix1, Matrix matrix2)Set to the difference ofmatrix1 - matrix2.StringtoString()Returns a string representation of this matrix.voidtranspose()Sets the value of this matrix to its transpose.voidtranspose(Matrix matrix)Set to the transpose of the provided matrix.
 
- 
- 
- 
Field Detail- 
SIZEpublic static final int SIZE The matrix size, which is 2.- See Also:
- Constant Field Values
 
 - 
m00public double m00 The first matrix element in the first row.
 - 
m01public double m01 The second matrix element in the first row.
 - 
m10public double m10 The first matrix element in the second row.
 - 
m11public double m11 The second matrix element in the second row.
 
- 
 - 
Constructor Detail- 
Matrix2public Matrix2() Creates a new identity matrix.
 - 
Matrix2public Matrix2(double m00, double m01, double m10, double m11)Creates a new matrix initialized to the specified values.
 - 
Matrix2public Matrix2(Matrix matrix) 
 
- 
 - 
Method Detail- 
getNumRowpublic final int getNumRow() Returns the number of rows in this matrix, which is always 2 in this implementation.
 - 
getNumColpublic final int getNumCol() Returns the number of colmuns in this matrix, which is always 2 in this implementation.
 - 
getElementpublic final double getElement(int row, int col)Returns the element at the specified index.- Specified by:
- getElementin interface- Matrix
- Specified by:
- getElementin interface- XMatrix
- Parameters:
- row- The row number to be retrieved (zero indexed).
- col- The column number to be retrieved (zero indexed).
- Returns:
- The value at the indexed element.
 
 - 
setElementpublic final void setElement(int row, int col, double value)Modifies the value at the specified row and column of this matrix.- Specified by:
- setElementin interface- Matrix
- Parameters:
- row- The row number to be retrieved (zero indexed).
- col- The column number to be retrieved (zero indexed).
- value- The new matrix element value.
 
 - 
setZeropublic final void setZero() Sets all the values in this matrix to zero.
 - 
setIdentitypublic final void setIdentity() Sets this matrix to the identity matrix.- Specified by:
- setIdentityin interface- XMatrix
 
 - 
isIdentitypublic final boolean isIdentity() Returnstrueif this matrix is an identity matrix.- Specified by:
- isIdentityin interface- Matrix
- Returns:
- trueif this matrix is an identity matrix.
 
 - 
isIdentitypublic 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 interface- XMatrix
- Parameters:
- tolerance- The tolerance value.
- Returns:
- trueif this matrix is close enough to the identity matrix given the tolerance value.
 
 - 
isAffinepublic 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.
 - 
negatepublic final void negate() Negates the value of this matrix:this = -this.
 - 
negatepublic void negate(Matrix matrix) Description copied from interface:XMatrixNegates the value of this matrix:this = -matrix.
 - 
transposepublic final void transpose() Sets the value of this matrix to its transpose.
 - 
transposepublic void transpose(Matrix matrix) Description copied from interface:XMatrixSet to the transpose of the provided matrix.
 - 
invertpublic final void invert() Inverts this matrix in place.
 - 
invertpublic void invert(Matrix matrix) throws SingularMatrixException Description copied from interface:XMatrixSet to the inverse of the provided matrix.- Specified by:
- invertin interface- XMatrix
- Parameters:
- matrix- The matrix that is to be inverted. Not modified.
- Throws:
- SingularMatrixException- if this matrix is not invertible.
 
 - 
multiplypublic final void multiply(Matrix matrix) Description copied from interface:XMatrixSets 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.
 - 
equalspublic boolean equals(Matrix matrix, double tolerance) Compares the element values.
 - 
equalspublic boolean equals(Object object) Returnstrueif the specified object is of typeMatrix2and all of the data members are equal to the corresponding data members in this matrix.
 - 
hashCodepublic int hashCode() Returns a hash code value based on the data values in this object.
 - 
toStringpublic String toString() Returns a string representation of this matrix. The returned string is implementation dependent. It is usually provided for debugging purposes only.
 - 
clonepublic Matrix2 clone() Returns a clone of this matrix.
 - 
getRowpublic void getRow(int row, double[] array)Description copied from interface:XMatrixExtract row to provided array
 - 
setRowpublic void setRow(int row, double... values)Description copied from interface:XMatrixSets the value of the row using an array of values.
 - 
getColumnpublic void getColumn(int column, double[] array)Description copied from interface:XMatrixExtract col to provided array.
 - 
setColumnpublic void setColumn(int column, double... values)Description copied from interface:XMatrixSets the value of the column using an array of values.
 - 
addpublic void add(double scalar) Description copied from interface:XMatrixPerforms an in-place scalar addition.
 - 
addpublic void add(double scalar, XMatrix matrix)Description copied from interface:XMatrixSet to the scalar addition ofscalar+matrix
 - 
addpublic void add(XMatrix matrix) Description copied from interface:XMatrixSet to the matrix addition ofthis+matrix.
 - 
addpublic void add(XMatrix matrix1, XMatrix matrix2) Description copied from interface:XMatrixSet to the matrix addition ofmatrix1+matrix2.
 - 
determinatepublic double determinate() Description copied from interface:XMatrixComputes the determinant- Specified by:
- determinatein interface- XMatrix
 
 - 
mulpublic void mul(double scalar) Description copied from interface:XMatrixSets this matrix to the result of multiplying itself with the provided scalar.
 - 
mulpublic void mul(double scalar, Matrix matrix)Description copied from interface:XMatrixSets the value of this matrix to the result of multiplying the provided scalar and matrix.
 - 
mulpublic void mul(Matrix matrix) Description copied from interface:XMatrixSets 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.
 - 
mulpublic void mul(Matrix matrix1, Matrix matrix2) Description copied from interface:XMatrixSets the value of this matrix to the result of multiplying matrix1 and matrix2.
 - 
subpublic void sub(double scalar) Description copied from interface:XMatrixIn-place matrix subtraction:this - scalar.
 - 
subpublic void sub(double scalar, Matrix matrix)Description copied from interface:XMatrixSet to the difference ofscalar - matrix2.
 - 
subpublic void sub(Matrix matrix) Description copied from interface:XMatrixIn-place matrix subtraction:this - matrix.
 
- 
 
-