hep.wired.util
Class Matrix2D

java.lang.Object
  extended by hep.wired.util.Matrix2D
All Implemented Interfaces:
UVWindices, XYZindices, Cloneable, org.freehep.xml.io.XMLIO

public class Matrix2D
extends Object
implements XYZindices, UVWindices, Cloneable, org.freehep.xml.io.XMLIO

A 2x3 matrix for projection of 2D space to 2D space.

Version:
$Id: Matrix2D.java 8598 2006-08-14 20:38:02Z duns $
Author:
Mark Donszelmann

Field Summary
 
Fields inherited from interface hep.wired.util.XYZindices
X, Y, Z
 
Fields inherited from interface hep.wired.util.UVWindices
U, V, W
 
Constructor Summary
Matrix2D()
          Creates an identity matrix.
Matrix2D(double m00, double m10, double m01, double m11, double m02, double m12)
          Creates a matrix with given parameters.
 
Method Summary
 Object clone()
           
 void concatenate(Matrix2D m)
          Concatenates this matrix with m, such that M' = M * m.
 Matrix2D createInverse()
           
 boolean equals(Object obj)
           
 double getDeterminant()
           
 double getScaleX()
           
 double getScaleY()
           
 double getShearX()
           
 double getShearY()
           
 double getTranslateX()
           
 double getTranslateY()
           
 int hashCode()
           
 void modelTranslate(double tx, double ty)
          Model-Translates by tx and ty.
 void preConcatenate(Matrix2D m)
          Pre-concatenates this matrix with m, such that M' = m * M.
 void restore(org.freehep.xml.io.XMLIOManager xmlioManager, org.jdom.Element nodeEl)
           
 void rotate(double theta)
          Rotates theta radians.
 void save(org.freehep.xml.io.XMLIOManager xmlioManager, org.jdom.Element nodeEl)
           
 void scale(double sx, double sy)
          Scales by sx and sy.
 void shear(double shx, double shy)
          Shears by shx and shy.
 String toString()
           
 double[][] transform(double[][] xyz, int n, boolean delta)
          Transforms xyz by this matrix for n points, using translation if delta is false.
 double[] transform(double[] xyz, boolean delta)
          Transforms xyz by this matrix, using translation if delta is false.
 void translate(double tx, double ty)
          Translates by tx and ty.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix2D

public Matrix2D()
Creates an identity matrix.


Matrix2D

public Matrix2D(double m00,
                double m10,
                double m01,
                double m11,
                double m02,
                double m12)
Creates a matrix with given parameters.

Parameters:
m00 - matrix param 00
m10 - matrix param 10
m01 - matrix param 01
m11 - matrix param 11
m02 - matrix param 02
m12 - matrix param 12
Method Detail

clone

public Object clone()
Overrides:
clone in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getScaleX

public double getScaleX()
Returns:
the sx value (m00).

getScaleY

public double getScaleY()
Returns:
the sy value (m11).

getShearX

public double getShearX()
Returns:
the shx value (m01).

getShearY

public double getShearY()
Returns:
the shy value (m10).

getTranslateX

public double getTranslateX()
Returns:
the tx value (m02).

getTranslateY

public double getTranslateY()
Returns:
the ty value (m12).

getDeterminant

public double getDeterminant()
Returns:
the determinant.

createInverse

public Matrix2D createInverse()
                       throws NoninvertibleTransformException
Returns:
the inverse of this matrix.
Throws:
NoninvertibleTransformException - if matrix cannot be inverted

concatenate

public void concatenate(Matrix2D m)
Concatenates this matrix with m, such that M' = M * m.

Parameters:
m - post matrix

preConcatenate

public void preConcatenate(Matrix2D m)
Pre-concatenates this matrix with m, such that M' = m * M.

Parameters:
m - pre matrix

rotate

public void rotate(double theta)
Rotates theta radians. Preconcatenates with the matrix:
   [   cos(theta)      -sin(theta)     0       ]
   [   sin(theta)      cos(theta)      0       ]
   [   0               0               1       ]
 

Parameters:
theta - angle

scale

public void scale(double sx,
                  double sy)
Scales by sx and sy. Preconcatenates with the matrix:
   [   sx              0               0       ]
   [   0               sy              0       ]
   [   0               0               1       ]
 

Parameters:
sx - scale factor in x
sy - scale factor in y

shear

public void shear(double shx,
                  double shy)
Shears by shx and shy. Preconcatenates with the matrix:
   [   1               shx             0       ]
   [   shy             1               0       ]
   [   0               0               1       ]
 

Parameters:
shx - shear factor in x
shy - shear factor in y

translate

public void translate(double tx,
                      double ty)
Translates by tx and ty. Preconcatenates with the matrix:
   [   1               0               tx      ]
   [   0               1               ty      ]
   [   0               0               1       ]
 

Parameters:
tx - translation in x
ty - translation in y

modelTranslate

public void modelTranslate(double tx,
                           double ty)
Model-Translates by tx and ty. Concatenates with the matrix:
   [   1               0               tx      ]
   [   0               1               ty      ]
   [   0               0               1       ]
 

Parameters:
tx - translation in x
ty - translation in y

transform

public double[] transform(double[] xyz,
                          boolean delta)
Transforms xyz by this matrix, using translation if delta is false. The input array is returned.

Parameters:
xyz - input xyz
delta - use translation
Returns:
uvw

transform

public double[][] transform(double[][] xyz,
                            int n,
                            boolean delta)
Transforms xyz by this matrix for n points, using translation if delta is false. The input array is returned.

Parameters:
xyz - input xyz
n - number of points
delta - use translation
Returns:
uvw

toString

public String toString()
Overrides:
toString in class Object

save

public void save(org.freehep.xml.io.XMLIOManager xmlioManager,
                 org.jdom.Element nodeEl)
Specified by:
save in interface org.freehep.xml.io.XMLIO

restore

public void restore(org.freehep.xml.io.XMLIOManager xmlioManager,
                    org.jdom.Element nodeEl)
Specified by:
restore in interface org.freehep.xml.io.XMLIO


Copyright © 1996-2013 FreeHEP. All Rights Reserved.