public class Matrix2 extends Object implements XMatrix, Serializable
Modifier and Type | Field and Description |
---|---|
double |
m00
The first matrix element in the first row.
|
double |
m01
The second matrix element in the first row.
|
double |
m10
The first matrix element in the second row.
|
double |
m11
The second matrix element in the second row.
|
static int |
SIZE
The matrix size, which is 2.
|
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
void |
add(double scalar)
Performs an in-place scalar addition.
|
void |
add(double scalar,
XMatrix matrix)
Set to the scalar addition of
scalar+matrix |
void |
add(XMatrix matrix)
Set to the matrix addition of
this+matrix . |
void |
add(XMatrix matrix1,
XMatrix matrix2)
Set to the matrix addition of
matrix1+matrix2 . |
Matrix2 |
clone()
Returns a clone of this matrix.
|
double |
determinate()
Computes the determinant
|
boolean |
equals(Matrix matrix,
double tolerance)
Compares the element values.
|
boolean |
equals(Object object)
Returns
true if the specified object is of type Matrix2 and all of the data
members are equal to the corresponding data members in this matrix. |
void |
getColumn(int column,
double[] array)
Extract col to provided array.
|
double |
getElement(int row,
int col)
Returns the element at the specified index.
|
int |
getNumCol()
Returns the number of colmuns in this matrix, which is always 2 in this
implementation.
|
int |
getNumRow()
Returns the number of rows in this matrix, which is always 2 in this
implementation.
|
void |
getRow(int row,
double[] array)
Extract row to provided array
|
int |
hashCode()
Returns a hash code value based on the data values in this object.
|
void |
invert()
Inverts this matrix in place.
|
void |
invert(Matrix matrix)
Set to the inverse of the provided matrix.
|
boolean |
isAffine()
Returns
true if this matrix is an affine transform. |
boolean |
isIdentity()
Returns
true if this matrix is an identity matrix. |
boolean |
isIdentity(double tolerance)
Returns
true if this matrix is an identity matrix using the provided tolerance. |
void |
mul(double scalar)
Sets this matrix to the result of multiplying itself with the provided scalar.
|
void |
mul(double scalar,
Matrix matrix)
Sets the value of this matrix to the result of multiplying the provided scalar and matrix.
|
void |
mul(Matrix matrix)
Sets the value of this matrix to the result of multiplying itself with the specified matrix.
|
void |
mul(Matrix matrix1,
Matrix matrix2)
Sets the value of this matrix to the result of multiplying matrix1 and matrix2.
|
void |
multiply(Matrix matrix)
Sets the value of this matrix to the result of multiplying itself with the specified matrix.
|
void |
negate()
Negates the value of this matrix:
this = -this . |
void |
negate(Matrix matrix)
Negates the value of this matrix:
this = -matrix . |
void |
setColumn(int column,
double... values)
Sets the value of the column using an array of values.
|
void |
setElement(int row,
int col,
double value)
Modifies the value at the specified row and column of this matrix.
|
void |
setIdentity()
Sets this matrix to the identity matrix.
|
void |
setRow(int row,
double... values)
Sets the value of the row using an array of values.
|
void |
setZero()
Sets all the values in this matrix to zero.
|
void |
sub(double scalar)
In-place matrix subtraction:
this - scalar . |
void |
sub(double scalar,
Matrix matrix)
Set to the difference of
scalar - matrix2 . |
void |
sub(Matrix matrix)
In-place matrix subtraction:
this - matrix . |
void |
sub(Matrix matrix1,
Matrix matrix2)
Set to the difference of
matrix1 - matrix2 . |
String |
toString()
Returns a string representation of this matrix.
|
void |
transpose()
Sets the value of this matrix to its transpose.
|
void |
transpose(Matrix matrix)
Set to the transpose of the provided matrix.
|
public static final int SIZE
public double m00
public double m01
public double m10
public double m11
public Matrix2()
public Matrix2(double m00, double m01, double m10, double m11)
public Matrix2(Matrix matrix)
public final int getNumRow()
public final int getNumCol()
public final double getElement(int row, int col)
getElement
in interface XMatrix
getElement
in interface Matrix
row
- The row number to be retrieved (zero indexed).col
- The column number to be retrieved (zero indexed).public final void setElement(int row, int col, double value)
setElement
in interface Matrix
row
- The row number to be retrieved (zero indexed).col
- The column number to be retrieved (zero indexed).value
- The new matrix element value.public final void setZero()
public final void setIdentity()
setIdentity
in interface XMatrix
public final boolean isIdentity()
true
if this matrix is an identity matrix.isIdentity
in interface Matrix
true
if this matrix is an identity matrix.public final boolean isIdentity(double tolerance)
true
if 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 returning true
if and only if all differences are smaller than
or equal to tolerance
.isIdentity
in interface XMatrix
tolerance
- The tolerance value.true
if this matrix is close enough to the identity matrix given the
tolerance value.public final boolean isAffine()
true
if 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.public final void negate()
this = -this
.public void negate(Matrix matrix)
XMatrix
this = -matrix
.public final void transpose()
public void transpose(Matrix matrix)
XMatrix
public final void invert()
public void invert(Matrix matrix) throws SingularMatrixException
XMatrix
invert
in interface XMatrix
matrix
- The matrix that is to be inverted. Not modified.SingularMatrixException
- if this matrix is not invertible.public final void multiply(Matrix matrix)
XMatrix
this
= this
× matrix
. In the context
of coordinate transformations, this is equivalent to
AffineTransform.concatenate
:
first transforms by the supplied transform and then transform the result by the original
transform.public boolean equals(Matrix matrix, double tolerance)
public boolean equals(Object object)
true
if the specified object is of type Matrix2
and all of the data
members are equal to the corresponding data members in this matrix.public int hashCode()
public String toString()
public Matrix2 clone()
clone
in interface Matrix
clone
in class Object
Object.clone()
public void getRow(int row, double[] array)
XMatrix
public void setRow(int row, double... values)
XMatrix
public void getColumn(int column, double[] array)
XMatrix
public void setColumn(int column, double... values)
XMatrix
public void add(double scalar)
XMatrix
public void add(double scalar, XMatrix matrix)
XMatrix
scalar+matrix
public void add(XMatrix matrix)
XMatrix
this+matrix
.public void add(XMatrix matrix1, XMatrix matrix2)
XMatrix
matrix1+matrix2
.public double determinate()
XMatrix
determinate
in interface XMatrix
public void mul(double scalar)
XMatrix
public void mul(double scalar, Matrix matrix)
XMatrix
public void mul(Matrix matrix)
XMatrix
this
= this
× matrix
. In the context
of coordinate transformations, this is equivalent to
AffineTransform.concatenate
:
first transforms by the supplied transform and then transform the result by the original
transform.public void mul(Matrix matrix1, Matrix matrix2)
XMatrix
public void sub(double scalar)
XMatrix
this - scalar
.public void sub(double scalar, Matrix matrix)
XMatrix
scalar - matrix2
.public void sub(Matrix matrix)
XMatrix
this - matrix
.Copyright © 1996–2019 Geotools. All rights reserved.