001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2005-2006, GeoTools Project Managment Committee (PMC)
005: * (C) 2005, Institut de Recherche pour le Développement
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation;
010: * version 2.1 of the License.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017: package org.geotools.referencing.operation.matrix;
018:
019: // Java3D dependencies
020: import javax.vecmath.SingularMatrixException;
021:
022: // OpenGIS dependencies
023: import org.opengis.referencing.operation.Matrix;
024:
025: /**
026: * A matrix capables to perform some matrix operations. The basic {@link Matrix} interface
027: * is basically just a two dimensional array of numbers. The {@code XMatrix} interface add
028: * {@linkplain #invert inversion} and {@linkplain #multiply multiplication} capabilities.
029: * It is used as a bridge across various matrix implementations in Java3D
030: * ({@link javax.vecmath.Matrix3f}, {@link javax.vecmath.Matrix3d}, {@link javax.vecmath.Matrix4f},
031: * {@link javax.vecmath.Matrix4d}, {@link javax.vecmath.GMatrix}).
032: *
033: * @since 2.2
034: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/main/java/org/geotools/referencing/operation/matrix/XMatrix.java $
035: * @version $Id: XMatrix.java 24493 2007-02-17 17:28:12Z desruisseaux $
036: * @author Martin Desruisseaux
037: * @author Simone Giannecchini
038: */
039: public interface XMatrix extends Matrix {
040: /**
041: * Returns the number of rows in this matrix.
042: */
043: int getNumRow();
044:
045: /**
046: * Returns the number of colmuns in this matrix.
047: */
048: int getNumCol();
049:
050: /**
051: * Returns the element at the specified index.
052: */
053: double getElement(int row, int col);
054:
055: /**
056: * Set the element at the specified index.
057: */
058: void setElement(int row, int col, double value);
059:
060: /**
061: * Sets all the values in this matrix to zero.
062: */
063: void setZero();
064:
065: /**
066: * Sets this matrix to the identity matrix.
067: */
068: void setIdentity();
069:
070: /**
071: * Returns {@code true} if this matrix is an identity matrix.
072: */
073: boolean isIdentity();
074:
075: /**
076: * Returns {@code true} if this matrix is an identity matrix using the provided tolerance.
077: * This method is equivalent to computing the difference between this matrix and an identity
078: * matrix of identical size, and returning {@code true} if and only if all differences are
079: * smaller than or equal to {@code tolerance}.
080: *
081: * @since 2.4
082: */
083: boolean isIdentity(double tolerance);
084:
085: /**
086: * Returns {@code true} if this matrix is an affine transform.
087: * A transform is affine if the matrix is square and last row contains
088: * only zeros, except in the last column which contains 1.
089: */
090: boolean isAffine();
091:
092: /**
093: * Negates the value of this matrix: {@code this} = {@code -this}.
094: */
095: void negate();
096:
097: /**
098: * Sets the value of this matrix to its transpose.
099: */
100: void transpose();
101:
102: /**
103: * Inverts this matrix in place.
104: *
105: * @throws SingularMatrixException if this matrix is not invertible.
106: */
107: void invert() throws SingularMatrixException;
108:
109: /**
110: * Sets the value of this matrix to the result of multiplying itself with the specified matrix.
111: * In other words, performs {@code this} = {@code this} × {@code matrix}. In the context
112: * of coordinate transformations, this is equivalent to
113: * <code>{@linkplain java.awt.geom.AffineTransform#concatenate AffineTransform.concatenate}</code>:
114: * first transforms by the supplied transform and then transform the result by the original
115: * transform.
116: */
117: void multiply(Matrix matrix);
118: }
|