Class Matrix

java.lang.Object
org.jlab.detector.geant4.v2.SVT.Matrix

public class Matrix extends Object

Geometry Base Link icon

Universal class for simple matrix algebra and rotation conversions.
Version:
1.1.0
Author:
pdavies
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    Matrix(int aNRows, int aNCols)
    Constructs a new Matrix with given rows and columns, and allocates an empty data array.
    Matrix(int aNRows, int aNCols, double[] aData)
    Constructs a new Matrix with given rows, columns, and data.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    Clones this Matrix.
    static Matrix
    convertRotationAxisAngleToMatrix(double[] aAxisAngle)
    Converts the given axis-angle rotation to a rotation matrix.
    static Matrix
    convertRotationFromEulerInXYZ_ExZYX(double angle_x, double angle_y, double angle_z)
    Converts the given Tait-Bryan angles to a rotation matrix.
    static Matrix
    convertRotationFromEulerInZYX_ExXYZ(double angle_x, double angle_y, double angle_z)
    Converts the given Tait-Bryan angles to a rotation matrix.
    static double[]
    Converts the given rotation matrix to Tait-Bryan angles.
    double[]
    Returns the data array of this Matrix.
    static Matrix
    matMul(Matrix aMatrixA, Matrix aMatrixB)
    Multiplies the two given matrices together with matrix multiplication.
    static Matrix
    rotateX(double angle)
    Constructs a rotation matrix for rotation about the X axis by the given angle.
    static Matrix
    rotateY(double angle)
    Constructs a rotation matrix for rotation about the Y axis by the given angle.
    static Matrix
    rotateZ(double angle)
    Constructs a rotation matrix for rotation about the Z axis by the given angle.
    void
    Prints data array with format "% 8.3f" for each element.
    void
    Prints the given string to standard output, followed by show().
    static Matrix
    transpose(Matrix aMatrix)
    Returns a transposed clone of the given Matrix.
    boolean
    Returns true if the length of the data array is equal to the product of the number of rows and columns.

    Methods inherited from class java.lang.Object Link icon

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details Link icon

  • Method Details Link icon

    • getData Link icon

      public double[] getData()
      Returns the data array of this Matrix.
      Returns:
      double[] array
    • clone Link icon

      public Matrix clone()
      Clones this Matrix.
      Overrides:
      clone in class Object
    • verify Link icon

      public boolean verify()
      Returns true if the length of the data array is equal to the product of the number of rows and columns.
      Returns:
      boolean true/false
    • show Link icon

      public void show(String s)
      Prints the given string to standard output, followed by show().
      Parameters:
      s - string
    • show Link icon

      public void show() throws NullPointerException
      Prints data array with format "% 8.3f" for each element.
      Throws:
      NullPointerException - no data
    • rotateX Link icon

      public static Matrix rotateX(double angle)
      Constructs a rotation matrix for rotation about the X axis by the given angle.
      Parameters:
      angle - in radians
      Returns:
      Matrix column-based rotation matrix
    • rotateY Link icon

      public static Matrix rotateY(double angle)
      Constructs a rotation matrix for rotation about the Y axis by the given angle.
      Parameters:
      angle - in radians
      Returns:
      Matrix column-based rotation matrix
    • rotateZ Link icon

      public static Matrix rotateZ(double angle)
      Constructs a rotation matrix for rotation about the Z axis by the given angle.
      Parameters:
      angle - in radians
      Returns:
      Matrix column-based rotation matrix
    • convertRotationAxisAngleToMatrix Link icon

      public static Matrix convertRotationAxisAngleToMatrix(double[] aAxisAngle)
      Converts the given axis-angle rotation to a rotation matrix. http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/
      Parameters:
      aAxisAngle - axis-angle rotation, format: { rx, ry, rz, ra }, angle in radians
      Returns:
      Matrix a column-based rotation matrix
    • convertRotationFromEulerInZYX_ExXYZ Link icon

      public static Matrix convertRotationFromEulerInZYX_ExXYZ(double angle_x, double angle_y, double angle_z)
      Converts the given Tait-Bryan angles to a rotation matrix. Tait-Bryan Euler: intrinsic ZY'X" == extrinsic XYZ rotation matrix M = Z(c)*Y(b)*X(a) http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q36
      Parameters:
      angle_x - in radians
      angle_y - in radians
      angle_z - in radians
      Returns:
      Matrix a column-based rotation matrix
    • convertRotationFromEulerInXYZ_ExZYX Link icon

      public static Matrix convertRotationFromEulerInXYZ_ExZYX(double angle_x, double angle_y, double angle_z)
      Converts the given Tait-Bryan angles to a rotation matrix. Tait-Bryan Euler: intrinsic XY'Z" == extrinsic ZYX rotation matrix M = X(a)*Y(b)*Z(c) http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q36
      Parameters:
      angle_x - in radians
      angle_y - in radians
      angle_z - in radians
      Returns:
      Matrix a column-based rotation matrix
    • convertRotationToEulerInXYZ_ExZYX Link icon

      public static double[] convertRotationToEulerInXYZ_ExZYX(Matrix aMatrix)
      Converts the given rotation matrix to Tait-Bryan angles. Tait-Bryan Euler: intrinsic XY'Z" == extrinsic ZYX rotation matrix M = X(a)*Y(b)*Z(c)
      Parameters:
      aMatrix - a column-based rotation matrix
      Returns:
      double[] xyz angles in radians
    • transpose Link icon

      public static Matrix transpose(Matrix aMatrix)
      Returns a transposed clone of the given Matrix.
      Parameters:
      aMatrix - matrix
      Returns:
      Matrix tranposed clone
    • matMul Link icon

      public static Matrix matMul(Matrix aMatrixA, Matrix aMatrixB) throws IllegalArgumentException
      Multiplies the two given matrices together with matrix multiplication. R = AB
      Parameters:
      aMatrixA - matrix
      aMatrixB - matrix
      Returns:
      Matrix result
      Throws:
      IllegalArgumentException - check sizes of matrices