org.geotools.referencing.operation.matrix
Class Matrix4

Object
  extended by Matrix4d
      extended by Matrix4
All Implemented Interfaces:
Serializable, Cloneable, XMatrix, Matrix

public class Matrix4
extends Matrix4d
implements XMatrix

A matrix of fixed 4×4 size. This specialized matrix provides better accuracy than GeneralMatrix for matrix inversion and multiplication. It is used primarily for supporting datum shifts.

Since:
2.2
Author:
Martin Desruisseaux (IRD)
See Also:
Serialized Form
Module:

Field Summary
static int SIZE
          The matrix size, which is 4.
 
Fields inherited from class Matrix4d
m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33
 
Constructor Summary
Matrix4()
          Creates a new identity matrix.
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.
Matrix4(Matrix matrix)
          Creates a new matrix initialized to the same value than the specified one.
 
Method Summary
 Matrix4 clone()
          Returns a clone of this matrix.
 boolean equals(Matrix matrix, double tolerance)
          Compares the element values regardless the object class.
 int getNumCol()
          Returns the number of colmuns 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 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 multiply(Matrix matrix)
          Sets the value of this matrix to the result of multiplying itself with the specified matrix.
 String toString()
          Returns a string representation of this matrix.
 
Methods inherited from class Matrix4d
add, add, add, add, determinant, epsilonEquals, epsilonEquals, equals, equals, get, get, get, get, get, get, get, getColumn, getColumn, getElement, getRotationScale, getRotationScale, getRow, getRow, getScale, hashCode, invert, invert, mul, mul, mul, mul, mulTransposeBoth, mulTransposeLeft, mulTransposeRight, negate, negate, rotX, rotY, rotZ, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, setColumn, setColumn, setColumn, setElement, setIdentity, setRotation, setRotation, setRotation, setRotation, setRotation, setRotationScale, setRotationScale, setRow, setRow, setRow, setScale, setTranslation, setZero, sub, sub, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transpose, transpose
 
Methods inherited from class Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface XMatrix
getElement, invert, negate, setElement, setIdentity, setZero, transpose
 

Field Detail

SIZE

public static final int SIZE
The matrix size, which is 4.

See Also:
Constant Field Values
Constructor Detail

Matrix4

public Matrix4()
Creates a new identity matrix.


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)
Creates a new matrix initialized to the specified values.


Matrix4

public Matrix4(Matrix matrix)
Creates a new matrix initialized to the same value than the specified one. The specified matrix size must be 4×4.

Method Detail

getNumRow

public final int getNumRow()
Returns the number of rows in this matrix, which is always 4 in this implementation.

Specified by:
getNumRow in interface XMatrix
Specified by:
getNumRow in interface Matrix

getNumCol

public final int getNumCol()
Returns the number of colmuns in this matrix, which is always 4 in this implementation.

Specified by:
getNumCol in interface XMatrix
Specified by:
getNumCol in interface Matrix

isIdentity

public final boolean isIdentity()
Returns true if this matrix is an identity matrix.

Specified by:
isIdentity in interface XMatrix
Specified by:
isIdentity in interface Matrix

isIdentity

public final boolean isIdentity(double tolerance)
Returns 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.

Specified by:
isIdentity in interface XMatrix
Parameters:
tolerance - The tolerance value.
Returns:
true if this matrix is close enough to the identity matrix given the tolerance value.

isAffine

public final boolean isAffine()
Returns 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.

Specified by:
isAffine in interface XMatrix
Returns:
true if this matrix is affine.

multiply

public final void multiply(Matrix matrix)
Sets the value of this matrix to the result of multiplying itself with the specified matrix. In other words, performs 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.

Specified by:
multiply in interface XMatrix
Parameters:
matrix - The matrix to multiply to this matrix.

equals

public boolean equals(Matrix matrix,
                      double tolerance)
Compares the element values regardless the object class. This is similar to a call to GMatrix.epsilonEquals(matrix, tolerance). The method name is intentionally different in order to avoid ambiguities at compile-time.

Specified by:
equals in interface XMatrix
Parameters:
matrix - The matrix to compare.
tolerance - The tolerance value.
Returns:
true if this matrix is close enough to the given matrix given the tolerance value.

toString

public String toString()
Returns a string representation of this matrix. The returned string is implementation dependent. It is usually provided for debugging purposes only.

Overrides:
toString in class Matrix4d

clone

public Matrix4 clone()
Returns a clone of this matrix.

Specified by:
clone in interface Matrix
Overrides:
clone in class Matrix4d


Copyright © 1996-2009 Geotools. All Rights Reserved.