org.geotoolkit.referencing.operation.matrix
Class Matrix4

Object
  extended by Matrix4d
      extended by Matrix4
All Implemented Interfaces:
Serializable, Cloneable, XMatrix, LenientComparable, 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
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 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[] 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.
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.
 boolean equals(Object object, ComparisonMode mode)
          Compares this matrix with the given object for equality.
 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
equals, 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 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.

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

Matrix4

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

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

Matrix4

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

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 4 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 4 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.

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. 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 Matrix4d

clone

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

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


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