public final class Matrix2 extends MatrixSIS
MathTransform2D
derivative computation.
The matrix members are:
┌ ┐ │ m00 m01 │ │ m10 m11 │ └ ┘
Matrix1
,
Matrix3
,
Matrix4
,
Serialized FormDefined in the sis-referencing
module
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[] elements)
Creates a new matrix initialized to the specified values.
|
Matrix2(double m00,
double m01,
double m10,
double m11)
Creates a new matrix initialized to the specified values.
|
Modifier and Type | Method and Description |
---|---|
static Matrix2 |
castOrCopy(Matrix matrix)
Casts or copies the given matrix to a
Matrix2 implementation. |
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. |
double |
getElement(int row,
int column)
Retrieves the value at the specified row and column of this matrix.
|
double[] |
getElements()
Returns all matrix elements in a flat, row-major (column indices vary fastest) array.
|
int |
getNumCol()
Returns the number of columns 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.
|
int |
hashCode()
Returns a hash code value based on the data values in this object.
|
boolean |
isAffine()
Returns
true if this matrix represents an affine transform. |
boolean |
isIdentity()
Returns
true if this matrix is an identity matrix. |
void |
normalizeColumns()
Normalizes all columns in-place.
|
void |
setElement(int row,
int column,
double value)
Modifies the value at the specified row and column of this matrix.
|
void |
setElements(double[] elements)
Sets all matrix elements from a flat, row-major (column indices vary fastest) array.
|
void |
transpose()
Sets the value of this matrix to its transpose.
|
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)
m00
- The first matrix element in the first row.m01
- The second matrix element in the first row.m10
- The first matrix element in the second row.m11
- The second matrix element in the second row.public Matrix2(double[] elements) throws IllegalArgumentException
elements
- Elements of the matrix. Column indices vary fastest.IllegalArgumentException
- If the given array does not have the expected length.setElements(double[])
,
Matrices.create(int, int, double[])
public static Matrix2 castOrCopy(Matrix matrix) throws MismatchedMatrixSizeException
Matrix2
implementation. If the given matrix
is already an instance of Matrix2
, then it is returned unchanged. Otherwise this method
verifies the matrix size, then copies all elements in a new Matrix2
object.matrix
- The matrix to cast or copy, or null
.null
argument),
or a copy of the given matrix otherwise.MismatchedMatrixSizeException
- If the size of the given matrix is not 2×2.public final int getNumRow()
public final int getNumCol()
public final double getElement(int row, int column)
Matrix2
,
then the m00
… m11
fields can be read directly for efficiency.getElement
in interface Matrix
getElement
in class MatrixSIS
row
- The row index, which can only be 0 or 1.column
- The column index, which can only be 0 or 1.public final void setElement(int row, int column, double value)
Matrix2
,
then the m00
… m11
fields can be set directly for efficiency.row
- The row index, which can only be 0 or 1.column
- The column index, which can only be 0 or 1.value
- The new value to set at the given row and column.public final double[] getElements()
getElements
in class MatrixSIS
public final void setElements(double[] elements)
setElements
in class MatrixSIS
elements
- The new matrix elements in a row-major array.Matrices.create(int, int, double[])
public final boolean isAffine()
true
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.isAffine
in class MatrixSIS
true
if this matrix represents an affine transform.Matrices.isAffine(Matrix)
public final boolean isIdentity()
true
if 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);
isIdentity
in interface Matrix
isIdentity
in class MatrixSIS
true
if this matrix is an identity matrix.Matrices.isIdentity(Matrix, double)
,
AffineTransform.isIdentity()
public void transpose()
public void normalizeColumns()
This method is useful when the matrix is a transform derivative. In such matrix, each column is a vector representing the displacement in target space when an ordinate in the source space is increased by one. Invoking this method turns those vectors into unitary vectors, which is useful for forming the basis of a new coordinate system.
normalizeColumns
in class MatrixSIS
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.equals
in interface LenientComparable
equals
in class Object
object
- The object to compare with this matrix for equality.true
if the given object is equal to this matrix.ComparisonMode.STRICT
Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.