hep.wired.util
Class Matrix3D

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

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

A 3x4 matrix for projections of 3D space to 3D space.

Version:
$Id: Matrix3D.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
Matrix3D()
          Creates an identity matrix.
Matrix3D(double m00, double m10, double m20, double m01, double m11, double m21, double m02, double m12, double m22, double m03, double m13, double m23)
          Creates a matrix with given parameters.
 
Method Summary
 Object clone()
           
 void concatenate(Matrix3D m)
          Concatenates this matrix with m, such that M' = M * m.
 Matrix3D createInverse()
          Creates and returns the inverse of this matrix.
 Matrix3D createNormalized()
          Create and returnes a normalized matrix of this matrix.
 Matrix3D createOrthonormalized()
          Create and return the orthonormalized rotation matrix by using the Gram-Schmidt algorithm.
 boolean equals(Object obj)
           
 double getDeterminant()
          Returns the determinant.
static Matrix3D getRotateInstance(double phi, double theta, double omega)
          Returns a rotate matrix to rotate omega over the Z-axis, theta over the X-axis, followed phi over the Y-axis.
static Matrix3D getRotateInstance(double theta, double nx, double ny, double nz)
          Returns a rotate matrix to rotate theta radians over unit vector (nx, ny, nz).
 double getRotation(double[] n)
          Returns the angle and unit vector of the rotation matrix of this matrix.
 double getScaleX()
          Returns the sx value (m00).
 double getScaleY()
          Returns the sy value (m11).
 double getScaleZ()
          Returns the sz value (m22).
 double getTranslateX()
          Returns the tx value (m03).
 double getTranslateY()
          Returns the ty value (m13).
 double getTranslateZ()
          Returns the tz value (m23).
 int hashCode()
           
 void modelTranslate(double tx, double ty, double tz)
          Model-Translates by tx, ty and tz.
 void preConcatenate(Matrix3D 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, double nx, double ny, double nz)
          Rotates theta radians over unit vector (nx, ny, nz).
 void rotateX(double phi)
          Rotate phi radians over x-axis, where y to z is a positive rotation.
 void rotateY(double theta)
          Rotate theta radians over y-axis, where z to x is a positive rotation.
 void rotateZ(double omega)
          Rotate omega radians over z-axis, where x to y is a positive rotation.
 void save(org.freehep.xml.io.XMLIOManager xmlioManager, org.jdom.Element nodeEl)
           
 void scale(double sx, double sy, double sz)
          Scales by sx, sy and sz.
 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, double tz)
          Translates by tx, ty and tz.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix3D

public Matrix3D()
Creates an identity matrix.


Matrix3D

public Matrix3D(double m00,
                double m10,
                double m20,
                double m01,
                double m11,
                double m21,
                double m02,
                double m12,
                double m22,
                double m03,
                double m13,
                double m23)
Creates a matrix with given parameters.

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


getScaleZ

public double getScaleZ()
Returns the sz value (m22).


getTranslateX

public double getTranslateX()
Returns the tx value (m03).


getTranslateY

public double getTranslateY()
Returns the ty value (m13).


getTranslateZ

public double getTranslateZ()
Returns the tz value (m23).


getRotateInstance

public static Matrix3D getRotateInstance(double theta,
                                         double nx,
                                         double ny,
                                         double nz)
Returns a rotate matrix to rotate theta radians over unit vector (nx, ny, nz).
   [cos(theta)+nx*nx*(1-cos(theta))    nx*ny*(1-cos(theta))-nz*sin(theta)  nx*nz*(1-cos(theta))+ny*sin(theta)  0   ]
   [ny*nx*(1-cos(theta)+nz*sin(theta)  cos(theta)+ny*ny*(1-cos(theta))     ny*nz*(1-cos(theta))-nz*sin(theta)  0   ]
   [nz*nx*(1-cos(theta)-ny*sin(theta)  nz*ny*(1-cos(theta))+nx*sin(theta)  cos(theta)+nz*nz*(1-cos(theta))     0   ]
   [0                                  0                                   0                                   1   ]
 
see "M.Pique, Matrix Techniques, Graphics Gems I [GLASSNER, 1990], pp. 465-469"


getRotateInstance

public static Matrix3D getRotateInstance(double phi,
                                         double theta,
                                         double omega)
Returns a rotate matrix to rotate omega over the Z-axis, theta over the X-axis, followed phi over the Y-axis.


rotateX

public void rotateX(double phi)
Rotate phi radians over x-axis, where y to z is a positive rotation. Concatenates with matrix:
  [1               0               0               0]
  [0               cos(phi)        -sin(phi)       0]
  [0               sin(phi)        cos(phi)        0]
  [0               0               0               1]  
 
See "Foley, van Dam, Computer Graphics, 1990, pp.213-222"


rotateY

public void rotateY(double theta)
Rotate theta radians over y-axis, where z to x is a positive rotation. Concatenates with matrix:
  [cos(theta)      0               sin(theta)      0]
  [0               1               0               0]
  [-sin(theta)     0               cos(theta)      0]
  [0               0               0               1]
 
See "Foley, van Dam, Computer Graphics, 1990, pp.213-222"


rotateZ

public void rotateZ(double omega)
Rotate omega radians over z-axis, where x to y is a positive rotation. Concatenates with matrix:
  [cos(omega)      -sin(omega)     0               0]
  [sin(omega)      cos(omega)      0               0]
  [0               0               1               0]
  [0               0               0               1]
 
See "Foley, van Dam, Computer Graphics, 1990, pp.213-222"


rotate

public void rotate(double theta,
                   double nx,
                   double ny,
                   double nz)
Rotates theta radians over unit vector (nx, ny, nz). Preconcatenates with the matrix:
   [cos(theta)+nx*nx*(1-cos(theta))    nx*ny*(1-cos(theta))-nz*sin(theta)  nx*nz*(1-cos(theta))+ny*sin(theta)  0   ]
   [ny*nx*(1-cos(theta)+nz*sin(theta)  cos(theta)+ny*ny*(1-cos(theta))     ny*nz*(1-cos(theta))-nz*sin(theta)  0   ]
   [nz*nx*(1-cos(theta)-ny*sin(theta)  nz*ny*(1-cos(theta))+nx*sin(theta)  cos(theta)+nz*nz*(1-cos(theta))     0   ]
   [0                                  0                                   0                                   1   ]
 
see "M.Pique, Matrix Techniques, Graphics Gems I [GLASSNER, 1990], pp. 465-469"


scale

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


shear

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


translate

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


modelTranslate

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


getRotation

public double getRotation(double[] n)
Returns the angle and unit vector of the rotation matrix of this matrix.


getDeterminant

public double getDeterminant()
Returns the determinant.


createOrthonormalized

public Matrix3D createOrthonormalized()
Create and return the orthonormalized rotation matrix by using the Gram-Schmidt algorithm.


createNormalized

public Matrix3D createNormalized()
Create and returnes a normalized matrix of this matrix.


createInverse

public Matrix3D createInverse()
                       throws NoninvertibleTransformException
Creates and returns the inverse of this matrix.

Throws:
NoninvertibleTransformException

concatenate

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


preConcatenate

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


transform

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


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.


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.