org.geotools.referencing.operation.matrix
Class Matrix3

Object
  extended by Matrix3d
      extended by Matrix3
All Implemented Interfaces:
Serializable, Cloneable, XMatrix, Matrix

public class Matrix3
extends Matrix3d
implements XMatrix

A matrix of fixed 3×3 size. This specialized matrix provides better accuracy than GeneralMatrix for matrix inversion and multiplication.

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

Field Summary
static int SIZE
          The matrix size, which is 3.
 
Fields inherited from class Matrix3d
m00, m01, m02, m10, m11, m12, m20, m21, m22
 
Constructor Summary
Matrix3()
          Creates a new identity matrix.
Matrix3(AffineTransform transform)
          Constructs a 3×3 matrix from the specified affine transform.
Matrix3(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
          Creates a new matrix initialized to the specified values.
Matrix3(Matrix matrix)
          Creates a new matrix initialized to the same value than the specified one.
 
Method Summary
 Matrix3 clone()
          Returns a clone of this matrix.
 boolean equals(Matrix matrix, double tolerance)
          Compares the element values regardless the object class.
 boolean equalsAffine(AffineTransform transform)
          Returns true if this matrix is equals to the specified affine transform.
 int getNumCol()
          Returns the number of colmuns in this matrix, which is always 3 in this implementation.
 int getNumRow()
          Returns the number of rows in this matrix, which is always 3 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.
 boolean isNaN()
          Returns true if at least one value is NaN.
 void multiply(Matrix matrix)
          Sets the value of this matrix to the result of multiplying itself with the specified matrix.
 void setMatrix(AffineTransform transform)
          Sets this matrix to the specified affine transform.
 String toString()
          Returns a string representation of this matrix.
 
Methods inherited from class Matrix3d
add, add, add, add, determinant, epsilonEquals, equals, equals, getColumn, getColumn, getElement, getRow, getRow, getScale, hashCode, invert, invert, mul, mul, mul, mul, mulNormalize, mulNormalize, mulTransposeBoth, mulTransposeLeft, mulTransposeRight, negate, negate, normalize, normalize, normalizeCP, normalizeCP, rotX, rotY, rotZ, set, set, set, set, set, set, set, set, setColumn, setColumn, setColumn, setElement, setIdentity, setRow, setRow, setRow, setScale, setZero, sub, sub, 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 3.

See Also:
Constant Field Values
Constructor Detail

Matrix3

public Matrix3()
Creates a new identity matrix.


Matrix3

public Matrix3(double m00,
               double m01,
               double m02,
               double m10,
               double m11,
               double m12,
               double m20,
               double m21,
               double m22)
Creates a new matrix initialized to the specified values.


Matrix3

public Matrix3(AffineTransform transform)
Constructs a 3×3 matrix from the specified affine transform.


Matrix3

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

Method Detail

getNumRow

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

Specified by:
getNumRow in interface XMatrix
Specified by:
getNumRow in interface Matrix
Returns:
The number of rows in this matrix.

getNumCol

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

Specified by:
getNumCol in interface XMatrix
Specified by:
getNumCol in interface Matrix
Returns:
The number of columns in this 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
Returns:
true if this matrix is an identity 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.

isNaN

public final boolean isNaN()
Returns true if at least one value is NaN.

Since:
2.3

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.

setMatrix

public void setMatrix(AffineTransform transform)
Sets this matrix to the specified affine transform.

Since:
2.3

equalsAffine

public boolean equalsAffine(AffineTransform transform)
Returns true if this matrix is equals to the specified affine transform.

Since:
2.3

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 Matrix3d

clone

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

Specified by:
clone in interface Matrix
Overrides:
clone in class Matrix3d
Returns:
A clone of this matrix.
See Also:
Object.clone()


Copyright © 1996-2014 Geotools. All Rights Reserved.