org.deegree_impl.model.pt
Class Matrix

java.lang.Object
  extended byGMatrix
      extended byorg.deegree_impl.model.pt.Matrix

public class Matrix
extends GMatrix

A two dimensional array of numbers. Row and column numbering begins with zero.

Version:
1.00
Author:
OpenGIS (www.opengis.org), Martin Desruisseaux
See Also:
PT_Matrix, javax.vecmath.GMatrix, AffineTransform, javax.media.jai.PerspectiveTransform, javax.media.j3d.Transform3D, Jama matrix, JSR-83 Multiarray package, Serialized Form

Field Summary
private static long serialVersionUID
          Serial number for interoperability with different versions.
 
Constructor Summary
  Matrix(java.awt.geom.AffineTransform transform)
          Construct a 3×3 matrix from the specified affine transform.
  Matrix(double[][] matrix)
          Constructs a new matrix from a two-dimensional array of doubles.
private Matrix(Envelope srcRegion, AxisOrientation[] srcAxis, Envelope dstRegion, AxisOrientation[] dstAxis, boolean validRegions)
          Construct an affine transform mapping a source region to a destination region.
  Matrix(int size)
          Construct a square identity matrix of size size × size.
  Matrix(int numRow, int numCol)
          Construct a matrix of size numRow × numCol.
  Matrix(int numRow, int numCol, double[] matrix)
          Constructs a numRow × numCol matrix initialized to the values in the matrix array.
 
Method Summary
static Matrix createAffineTransform(AxisOrientation[] srcAxis, AxisOrientation[] dstAxis)
          Construct an affine transform changing axis order and/or orientation.
static Matrix createAffineTransform(Envelope srcRegion, AxisOrientation[] srcAxis, Envelope dstRegion, AxisOrientation[] dstAxis)
          Construct an affine transform mapping a source region to a destination region.
static Matrix createAffineTransform(Envelope srcRegion, Envelope dstRegion)
          Construct an affine transform that maps a source region to a destination region.
 double[][] getElements()
          Retrieves the specifiable values in the transformation matrix into a 2-dimensional array of double precision values.
 boolean isAffine()
          Returns true if this matrix is an affine transform.
 boolean isIdentity()
          Returns true if this matrix is an identity matrix.
 java.awt.geom.AffineTransform toAffineTransform2D()
          Returns an affine transform for this matrix.
 java.lang.String toString()
          Returns a string representation of this matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serial number for interoperability with different versions.

See Also:
Constant Field Values
Constructor Detail

Matrix

public Matrix(int size)
Construct a square identity matrix of size size × size.


Matrix

public Matrix(int numRow,
              int numCol)
Construct a matrix of size numRow × numCol. Elements on the diagonal j==i are set to 1.


Matrix

public Matrix(int numRow,
              int numCol,
              double[] matrix)
Constructs a numRow × numCol matrix initialized to the values in the matrix array. The array values are copied in one row at a time in row major fashion. The array should be exactly numRow*numCol in length. Note that because row and column numbering begins with zero, row and numCol will be one larger than the maximum possible matrix index values.


Matrix

public Matrix(double[][] matrix)
       throws java.lang.IllegalArgumentException
Constructs a new matrix from a two-dimensional array of doubles.

Parameters:
matrix - Array of rows. Each row must have the same length.
Throws:
java.lang.IllegalArgumentException - if the specified matrix is not regular (i.e. if all rows doesn't have the same length).

Matrix

public Matrix(java.awt.geom.AffineTransform transform)
Construct a 3×3 matrix from the specified affine transform.


Matrix

private Matrix(Envelope srcRegion,
               AxisOrientation[] srcAxis,
               Envelope dstRegion,
               AxisOrientation[] dstAxis,
               boolean validRegions)
Construct an affine transform mapping a source region to a destination region. The regions must have the same number of dimensions, but their axis order and axis orientation may be different.

Parameters:
srcRegion - The source region.
srcAxis - Axis orientation for each dimension of the source region.
dstRegion - The destination region.
dstAxis - Axis orientation for each dimension of the destination region.
validRegions - true if source and destination regions must be taken in account. If false, then source and destination regions will be ignored and may be null.
Method Detail

createAffineTransform

public static Matrix createAffineTransform(AxisOrientation[] srcAxis,
                                           AxisOrientation[] dstAxis)
Construct an affine transform changing axis order and/or orientation. For example, the affine transform may convert (NORTH,WEST) coordinates into (EAST,NORTH). Axis orientation can be inversed only. For example, it is illegal to transform (NORTH,WEST) coordinates into (NORTH,DOWN).

Parameters:
srcAxis - The set of axis orientation for source coordinate system.
dstAxis - The set of axis orientation for destination coordinate system.
Throws:
MismatchedDimensionException - if srcAxis and dstAxis don't have the same length.
java.lang.IllegalArgumentException - if the affine transform can't be created for some other raison.

createAffineTransform

public static Matrix createAffineTransform(Envelope srcRegion,
                                           Envelope dstRegion)
Construct an affine transform that maps a source region to a destination region. Axis order and orientation are left unchanged.

Parameters:
srcRegion - The source region.
dstRegion - The destination region.
Throws:
MismatchedDimensionException - if regions don't have the same dimension.

createAffineTransform

public static Matrix createAffineTransform(Envelope srcRegion,
                                           AxisOrientation[] srcAxis,
                                           Envelope dstRegion,
                                           AxisOrientation[] dstAxis)
Construct an affine transform mapping a source region to a destination region. Axis order and/or orientation can be changed during the process. For example, the affine transform may convert (NORTH,WEST) coordinates into (EAST,NORTH). Axis orientation can be inversed only. For example, it is illegal to transform (NORTH,WEST) coordinates into (NORTH,DOWN).

Parameters:
srcRegion - The source region.
srcAxis - Axis orientation for each dimension of the source region.
dstRegion - The destination region.
dstAxis - Axis orientation for each dimension of the destination region.
Throws:
MismatchedDimensionException - if all arguments don't have the same dimension.
java.lang.IllegalArgumentException - if the affine transform can't be created for some other raison.

getElements

public final double[][] getElements()
Retrieves the specifiable values in the transformation matrix into a 2-dimensional array of double precision values. The values are stored into the 2-dimensional array using the row index as the first subscript and the column index as the second. Values are copied; changes to the returned array will not change this matrix.

See Also:
PT_Matrix.elt

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.


isIdentity

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


toAffineTransform2D

public final java.awt.geom.AffineTransform toAffineTransform2D()
                                                        throws java.lang.IllegalStateException
Returns an affine transform for this matrix. This is a convenience method for interoperability with Java2D.

Throws:
java.lang.IllegalStateException - if this matrix is not 3x3, or if the last row is not [0 0 1].

toString

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