Class Mat44

All Implemented Interfaces:
ConstJoltPhysicsObject, Mat44Arg, AutoCloseable, Comparable<ConstJoltPhysicsObject>

public final class Mat44 extends JoltPhysicsObject implements Mat44Arg
A 4x4 matrix composed of 16 single-precision elements, used to represent transformations of 3-D coordinates.
  • Constructor Details

    • Mat44

      public Mat44()
      Instantiate an uninitialized matrix.
    • Mat44

      public Mat44(float... elements)
      Instantiate a matrix with the specified elements.
      Parameters:
      elements - in column-major order (not null)
  • Method Details

    • setElement

      public void setElement(int row, int column, float value)
      Alter the specified element.
      Parameters:
      row - the zero-origin index of the row (≥0, <4)
      column - the zero-origin index of the column (≥0, <4)
      value - the desired value
    • sIdentity

      public static Mat44 sIdentity()
      Create an identity matrix.
      Returns:
      a new instance
    • sRotation

      public static Mat44 sRotation(QuatArg rotation)
      Create a matrix from the specified quaternion.
      Parameters:
      rotation - the rotation quaternion to use (not null, unaffected)
      Returns:
      a new instance
    • sZero

      public static Mat44 sZero()
      Create an all-zero matrix.
      Returns:
      a new instance
    • getElement

      public float getElement(int row, int column)
      Return the specified element. The matrix is unaffected.
      Specified by:
      getElement in interface Mat44Arg
      Parameters:
      row - the zero-origin index of the row (≥0, <4)
      column - the zero-origin index of the column (≥0, <4)
      Returns:
      the element's value
    • getQuaternion

      public Quat getQuaternion()
      Convert the rotation to a Quat. The matrix is unaffected.
      Specified by:
      getQuaternion in interface Mat44Arg
      Returns:
      a new rotation quaternion
    • isEqual

      public boolean isEqual(Mat44Arg m2)
      Test whether the current matrix is equal to the argument. The current matrix is unaffected.
      Specified by:
      isEqual in interface Mat44Arg
      Parameters:
      m2 - the 2nd matrix to test (not null, unaffected)
      Returns:
      true if equal, false if unequal
    • multiply3x3

      public Mat44 multiply3x3(Mat44Arg arg)
      Multiply the current 3x3 matrix by the specified 3x3 matrix. The matrix is unaffected.
      Specified by:
      multiply3x3 in interface Mat44Arg
      Parameters:
      arg - the factor (not null, unaffected)
      Returns:
      a new matrix
    • multiply3x3

      public Vec3 multiply3x3(Vec3Arg vec3Arg)
      Multiply the 3x3 matrix by the specified vector. The matrix is unaffected.
      Specified by:
      multiply3x3 in interface Mat44Arg
      Parameters:
      vec3Arg - the right factor (not null, unaffected)
      Returns:
      a new vector
    • multiply3x3Transposed

      public Vec3 multiply3x3Transposed(Vec3Arg vec3Arg)
      Multiply the transpose of the 3x3 matrix by the specified vector. The matrix is unaffected.
      Specified by:
      multiply3x3Transposed in interface Mat44Arg
      Parameters:
      vec3Arg - the right factor (not null, unaffected)
      Returns:
      a new vector
    • toString

      public String toString()
      Return a string representation of the matrix, which is unaffected. For example, an identity matrix is represented by:
       Mat44[
        1.0  0.0  0.0  0.0
        0.0  1.0  0.0  0.0
        0.0  0.0  1.0  0.0
        0.0  0.0  0.0  1.0
       ]
       
      Overrides:
      toString in class JoltPhysicsObject
      Returns:
      the string representation (not null, not empty)