org.deegree.cs.utilities
Class Matrix

java.lang.Object
  extended by javax.vecmath.GMatrix
      extended by org.deegree.cs.utilities.Matrix
All Implemented Interfaces:
Serializable, Cloneable

public class Matrix
extends javax.vecmath.GMatrix

Defines a matrix based on GMatrix. Also suplies some methods to create a 'swap' matrix between two coordinate systems.

Version:
$Revision: 30120 $, $Date: 2011-03-22 10:04:15 +0100 (Tue, 22 Mar 2011) $
Author:
Rutger Bezema, last edited by: $Author: aschmitz $
See Also:
Serialized Form

Constructor Summary
Matrix(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.
Matrix(javax.vecmath.GMatrix matrix)
          Constructs a new matrix and copies the initial values from the parameter matrix.
Matrix(IAxis[] srcAxis, IAxis[] dstAxis)
          Construct an affine transform changing axis order.
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
 boolean isAffine()
          Returns true if this matrix is an affine transform.
 boolean isIdentity()
          Returns true if this matrix is an identity matrix.
static Matrix swapAndRotateGeoAxis(IGeographicCRS sourceCRS, IGeographicCRS targetCRS)
           
static Matrix swapAxis(ICRS sourceCRS, ICRS targetCRS)
           
 javax.vecmath.Matrix3d toAffineTransform()
          Copies the first 2x3 values into an affine transform object.
static Matrix toStdValues(ICRS sourceCRS, boolean invert)
          Creates a matrix, with which incoming values will be transformed to a standardized form.
 
Methods inherited from class javax.vecmath.GMatrix
add, add, clone, copySubMatrix, epsilonEquals, epsilonEquals, equals, equals, get, get, get, get, get, getColumn, getColumn, getElement, getNumCol, getNumRow, getRow, getRow, hashCode, identityMinus, invert, invert, LUD, mul, mul, mul, mulTransposeBoth, mulTransposeLeft, mulTransposeRight, negate, negate, set, set, set, set, set, set, setColumn, setColumn, setElement, setIdentity, setRow, setRow, setScale, setSize, setZero, sub, sub, SVD, toString, trace, transpose, transpose
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix

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

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

Parameters:
numRow -
numCol -

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.

Parameters:
numRow -
numCol -
matrix -

Matrix

public Matrix(double[][] matrix)
       throws 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:
IllegalArgumentException - if the specified matrix is not regular (i.e. if all rows doesn't have the same length).

Matrix

public Matrix(javax.vecmath.GMatrix matrix)
Constructs a new matrix and copies the initial values from the parameter matrix.

Parameters:
matrix -

Matrix

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

Parameters:
transform -

Matrix

public Matrix(IAxis[] srcAxis,
              IAxis[] dstAxis)
Construct an affine transform changing axis order. The resulting affine transform will convert incoming coordinates into the given destination Axis. For example if source axis are given with (NORTH,WEST) and destination axis as (EAST,NORTH) assuming the axis use the same units, the resulted matrix will look like:
 0, 1, 0
-1, 0, 0
 0, 0, 1
Axis orientation can be inverted only. Rotating axis (e.g. from NORTH,WEST, to NORTH,DOWN, ) is not supported.

Parameters:
srcAxis - The set of axis orientation for source coordinate system.
dstAxis - The set of axis orientation for destination coordinate system.
Throws:
IllegalArgumentException - if the affine transform can't be created for some other reason.
Method Detail

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.

Returns:
true if this matrix is an affine transform.

toAffineTransform

public final javax.vecmath.Matrix3d toAffineTransform()
Copies the first 2x3 values into an affine transform object. If not enough values are available, an identity transform is returned.

Returns:
an affine transform for this matrix. or an identity if this matrix has not sufficient values.

isIdentity

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

Returns:
true if this matrix is an identity matrix.

swapAxis

public static Matrix swapAxis(ICRS sourceCRS,
                              ICRS targetCRS)
                       throws TransformationException
Parameters:
sourceCRS - The source coordinate system.
targetCRS - The target coordinate system.
Returns:
an affine transform between two coordinate systems. Only units and axis order (e.g. transforming from (NORTH,WEST) to (EAST,NORTH)) are taken in account. Other attributes (especially the datum) must be checked before invoking this method.
Throws:
TransformationException - if some error occurs.

swapAndRotateGeoAxis

public static Matrix swapAndRotateGeoAxis(IGeographicCRS sourceCRS,
                                          IGeographicCRS targetCRS)
                                   throws TransformationException
Parameters:
sourceCRS - The source coordinate system.
targetCRS - The target coordinate system.
Returns:
an affine transform between two geographic coordinate systems. Only units, axis order (e.g. transforming from (NORTH,WEST) to (EAST,NORTH)) and prime meridian are taken in account. Other attributes (especially the datum) must be checked before invoking this method.
Throws:
TransformationException - if some error occurs.

toStdValues

public static Matrix toStdValues(ICRS sourceCRS,
                                 boolean invert)
                          throws TransformationException
Creates a matrix, with which incoming values will be transformed to a standardized form. This means, to radians and meters.

Parameters:
sourceCRS - to create the matrix for.
invert - the values. Using the inverted scale, i.e. going from standard to crs specific.
Returns:
the standardized matrix.
Throws:
TransformationException - if the unit of one of the axis could not be transformed to one of the base units.


Copyright © 2011. All Rights Reserved.