org.geotoolkit.referencing.operation.matrix
Class Matrix3

Object
  extended by Matrix3d
      extended by Matrix3
All Implemented Interfaces:
Serializable, Cloneable, XMatrix, LenientComparable, 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
Version:
3.18
Author:
Martin Desruisseaux (IRD, Geomatys)
See Also:
Serialized Form
Module:
referencing/geotk-referencing (download)    View source code for this class

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[] elements)
          Creates a new matrix initialized to the specified values.
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 equals(Object object, ComparisonMode mode)
          Compares this matrix with the given object for equality.
 boolean equalsAffine(AffineTransform transform)
          Returns true if this matrix is equal 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 coefficient 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.
 AffineTransform toAffineTransform()
          Returns an affine transform for this matrix.
 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
invert, negate, setIdentity, setZero, transpose
 
Methods inherited from interface Matrix
getElement, setElement
 
Methods inherited from interface LenientComparable
equals
 

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.

Parameters:
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.
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.
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.

Matrix3

public Matrix3(double[] elements)
Creates a new matrix initialized to the specified values. The length of the given array must be 9 and the values in the same order than the above constructor.

Parameters:
elements - Elements of the matrix. Column indices vary fastest.
Since:
3.00

Matrix3

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

Parameters:
transform - The affine transform to copy.
See Also:
toAffineTransform()

Matrix3

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

Parameters:
matrix - The matrix to copy.
Throws:
IllegalArgumentException - if the given matrix is not of the expected size.
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 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 Matrix

isIdentity

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

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.

isNaN

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

Returns:
true if at least one coefficient 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.

Parameters:
transform - The affine transform to copy.
Since:
2.3

toAffineTransform

public AffineTransform toAffineTransform()
                                  throws IllegalStateException
Returns an affine transform for this matrix. This is a convenience method for inter-operability with Java2D.

Returns:
The affine transform for this matrix.
Throws:
IllegalStateException - if the last row is not [0 0 1].
Since:
3.00

equalsAffine

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

Parameters:
transform - The affine transform to test for equality.
Returns:
true if the given affine transform has the same coefficients than this matrix.
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. 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.

equals

public boolean equals(Object object,
                      ComparisonMode mode)
Compares this matrix with the given object for equality. To be considered equal, the two objects must meet the following conditions, which depend on the mode argument:

Specified by:
equals in interface XMatrix
Specified by:
equals in interface LenientComparable
Parameters:
object - The object to compare to this.
mode - The strictness level of the comparison.
Returns:
true if both objects are equal.
Since:
3.18

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 XMatrix
Specified by:
clone in interface Matrix
Overrides:
clone in class Matrix3d


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.