public final class Matrix4 extends MatrixSIS
┌ ┐ │ m00 m01 m02 m03 │ │ m10 m11 m12 m13 │ │ m20 m21 m22 m23 │ │ m30 m31 m32 m33 │ └ ┘
Matrix1
,
Matrix2
,
Matrix3
,
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 |
m02
The third matrix element in the first row.
|
double |
m03
The forth 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.
|
double |
m12
The third matrix element in the second row.
|
double |
m13
The forth matrix element in the second row.
|
double |
m20
The first matrix element in the third row.
|
double |
m21
The second matrix element in the third row.
|
double |
m22
The third matrix element in the third row.
|
double |
m23
The forth matrix element in the third row.
|
double |
m30
The first matrix element in the forth row.
|
double |
m31
The second matrix element in the forth row.
|
double |
m32
The third matrix element in the forth row.
|
double |
m33
The forth matrix element in the forth row.
|
static int |
SIZE
The matrix size, which is 4.
|
Constructor and Description |
---|
Matrix4()
Creates a new identity matrix.
|
Matrix4(double[] elements)
Creates a new matrix initialized to the specified values.
|
Matrix4(double m00,
double m01,
double m02,
double m03,
double m10,
double m11,
double m12,
double m13,
double m20,
double m21,
double m22,
double m23,
double m30,
double m31,
double m32,
double m33)
Creates a new matrix initialized to the specified values.
|
Modifier and Type | Method and Description |
---|---|
static Matrix4 |
castOrCopy(Matrix matrix)
Casts or copies the given matrix to a
Matrix4 implementation. |
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 4 in this implementation.
|
int |
getNumRow()
Returns the number of rows in this matrix, which is always 4 in this implementation.
|
boolean |
isAffine()
Returns
true if this matrix represents an affine transform. |
boolean |
isIdentity()
Returns
true if this matrix is an identity matrix. |
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.
|
clone, convertAfter, convertBefore, equals, equals, equals, getNumber, hashCode, inverse, multiply, normalizeColumns, solve, toString
public static final int SIZE
public double m00
public double m01
public double m02
public double m03
public double m10
public double m11
public double m12
public double m13
public double m20
public double m21
public double m22
public double m23
public double m30
public double m31
public double m32
public double m33
public Matrix4()
public Matrix4(double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33)
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.m03
- The forth 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.m13
- The forth 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.m23
- The forth matrix element in the third row.m30
- The first matrix element in the forth row.m31
- The second matrix element in the forth row.m32
- The third matrix element in the forth row.m33
- The forth matrix element in the forth row.public Matrix4(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 Matrix4 castOrCopy(Matrix matrix) throws MismatchedMatrixSizeException
Matrix4
implementation. If the given matrix
is already an instance of Matrix4
, then it is returned unchanged. Otherwise this method
verifies the matrix size, then copies all elements in a new Matrix4
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 4×4.public final int getNumRow()
public final int getNumCol()
public final double getElement(int row, int column)
Matrix4
,
then the m00
… m33
fields can be read directly for efficiency.getElement
in interface Matrix
getElement
in class MatrixSIS
row
- The row index, from 0 inclusive to 4 exclusive.column
- The column index, from 0 inclusive to 4 exclusive.public final void setElement(int row, int column, double value)
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)
,
LinearTransform.isAffine()
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()
Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.