All Implemented Interfaces:
ConstJoltPhysicsObject, RMat44Arg, AutoCloseable, Comparable<JoltPhysicsObject>

public final class RMat44 extends JoltPhysicsObject implements RMat44Arg
A 4x4 matrix used to represent transformations of 3-D coordinates.
  • Constructor Details

    • RMat44

      public RMat44()
      Instantiate an uninitialized matrix.
    • RMat44

      public RMat44(Mat44Arg spMatrix)
      Instantiate from a single-precision matrix.
      Parameters:
      spMatrix - the matrix to copy (not null, unaffected)
    • RMat44

      public RMat44(RMat44Arg original)
      Instantiate a copy of the specified matrix.
      Parameters:
      original - the matrix to duplicate (not null, unaffected)
    • RMat44

      public RMat44(Vec4Arg c1, Vec4Arg c2, Vec4Arg c3, RVec3Arg c4)
      Instantiate a matrix with the specified columns.
      Parameters:
      c1 - the desired first/leftmost column (not null, unaffected)
      c2 - the desired 2nd column (not null, unaffected)
      c3 - the desired 3rd column (not null, unaffected)
      c4 - the desired 4th/rightmost column (not null, unaffected)
  • Method Details

    • leftMultiplyInPlace

      public void leftMultiplyInPlace(RMat44Arg leftFactor)
      Left-multiply the current matrix by the argument.
      Parameters:
      leftFactor - the left factor (not null, unaffected)
    • loadIdentity

      public void loadIdentity()
      Set the current matrix to identity.
    • product

      public static RMat44 product(RMat44Arg... mArray)
      Return the product of the specified matrices.
      Parameters:
      mArray - an array of input matrices (not null, unaffected)
      Returns:
      a new matrix
    • rightMultiplyInPlace

      public void rightMultiplyInPlace(RMat44Arg rightFactor)
      Right-multiply the current matrix by the argument.
      Parameters:
      rightFactor - the right factor (not null, unaffected)
    • set

      public void set(RMat44Arg source)
      Copy all elements of the argument to the current matrix.
      Parameters:
      source - the matrix to copy (not null, unaffected)
    • setAxisX

      public void setAxisX(Vec3Arg vec)
      Set the first column to the specified vector.
      Parameters:
      vec - the vector to use (not null, unaffected)
    • setAxisY

      public void setAxisY(Vec3Arg vec)
      Set the 2nd column to the specified vector.
      Parameters:
      vec - the vector to use (not null, unaffected)
    • setAxisZ

      public void setAxisZ(Vec3Arg vec)
      Set the 3rd column to the specified vector.
      Parameters:
      vec - the vector to use (not null, unaffected)
    • setElement

      public void setElement(int row, int column, double value)
      Alter the specified element in double precision.
      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
    • setTranslation

      public void setTranslation(RVec3Arg offset)
      Alter the translation component.
      Parameters:
      offset - the desired translation (not null, unaffected)
    • sIdentity

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

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

      public static RMat44 sRotationTranslation(QuatArg rotation, RVec3Arg offset)
      Create a translation-and-rotation matrix.
      Parameters:
      rotation - the amount to rotate (not null, unaffected)
      offset - the amount to translate (not null, unaffected)
      Returns:
      a new object
    • sScale

      public static RMat44 sScale(float factor)
      Create a uniform scaling matrix.
      Parameters:
      factor - the amount to scale each axis
      Returns:
      a new matrix
    • sScale

      public static RMat44 sScale(Vec3Arg factors)
      Create a pure scaling matrix.
      Parameters:
      factors - the amount to scale each axis (not null, unaffected)
      Returns:
      a new matrix
    • sTranslation

      public static RMat44 sTranslation(RVec3Arg offset)
      Create a pure translation matrix.
      Parameters:
      offset - the amount to translate (not null, unaffected)
      Returns:
      a new matrix
    • sZero

      public static RMat44 sZero()
      Create an all-zero matrix.
      Returns:
      a new matrix
    • getAxisX

      public Vec3 getAxisX()
      Copy the first column to a Vec3. The matrix is unaffected.
      Specified by:
      getAxisX in interface RMat44Arg
      Returns:
      a new vector
    • getAxisY

      public Vec3 getAxisY()
      Copy the 2nd column to a Vec3. The matrix is unaffected.
      Specified by:
      getAxisY in interface RMat44Arg
      Returns:
      a new vector
    • getAxisZ

      public Vec3 getAxisZ()
      Copy the 3rd column to a Vec3. The matrix is unaffected.
      Specified by:
      getAxisZ in interface RMat44Arg
      Returns:
      a new vector
    • getDiagonal3

      public Vec3 getDiagonal3()
      Copy the diagonal elements to a Vec3. The matrix is unaffected.
      Specified by:
      getDiagonal3 in interface RMat44Arg
      Returns:
      a new vector
    • getElement

      public double getElement(int row, int column)
      Return the specified element in double precision. The matrix is unaffected.
      Specified by:
      getElement in interface RMat44Arg
      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 RMat44Arg
      Returns:
      a new rotation quaternion
    • getTranslation

      public RVec3 getTranslation()
      Copy the translation component. The matrix is unaffected.
      Specified by:
      getTranslation in interface RMat44Arg
      Returns:
      a new vector
    • inversed

      public RMat44 inversed()
      Return the inverse of the current matrix, which is unaffected.
      Specified by:
      inversed in interface RMat44Arg
      Returns:
      a new matrix
    • inversedRotationTranslation

      public RMat44 inversedRotationTranslation()
      Return the inverse of the current matrix, assuming the current matrix consists entirely of rotation and translation. The current matrix is unaffected.
      Specified by:
      inversedRotationTranslation in interface RMat44Arg
      Returns:
      a new matrix
    • isEqual

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

      public boolean isIdentity()
      Test whether the current matrix is an identity matrix. The matrix is unaffected.
      Specified by:
      isIdentity in interface RMat44Arg
      Returns:
      true if exactly equal, otherwise false
    • multiply

      public RMat44 multiply(Mat44Arg right)
      Multiply the current matrix by the specified single-precision matrix. The current matrix is unaffected.
      Specified by:
      multiply in interface RMat44Arg
      Parameters:
      right - the right factor (not null, unaffected)
      Returns:
      a new matrix
    • multiply

      public RMat44 multiply(RMat44Arg right)
      Multiply the current matrix by the argument. The current matrix is unaffected.
      Specified by:
      multiply in interface RMat44Arg
      Parameters:
      right - the right factor (not null, unaffected)
      Returns:
      a new matrix
    • multiply3x3

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

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

      public RVec3 multiply3x4(RVec3Arg rightVector)
      Multiply the 3x4 matrix by the specified column vector, with the 4th component of the right factor implied to be one. The matrix is unaffected.
      Specified by:
      multiply3x4 in interface RMat44Arg
      Parameters:
      rightVector - the right factor (not null, unaffected)
      Returns:
      a new vector
    • multiply3x4

      public RVec3 multiply3x4(Vec3Arg vec3)
      Multiply the 3x4 matrix by the specified column vector, with the 4th component of the right factor implied to be one. The matrix is unaffected.
      Specified by:
      multiply3x4 in interface RMat44Arg
      Parameters:
      vec3 - the right factor (not null, unaffected)
      Returns:
      a new vector
    • postTranslated

      public RMat44 postTranslated(RVec3Arg leftVector)
      Post multiply by the specified translation vector. The current matrix is unaffected.
      Specified by:
      postTranslated in interface RMat44Arg
      Parameters:
      leftVector - the left factor (not null, unaffected)
      Returns:
      a new matrix
    • postTranslated

      public RMat44 postTranslated(Vec3Arg vec3)
      Post multiply by the specified translation vector. The current matrix is unaffected.
      Specified by:
      postTranslated in interface RMat44Arg
      Parameters:
      vec3 - the left factor (not null, unaffected)
      Returns:
      a new matrix
    • put3x3ColumnMajor

      public void put3x3ColumnMajor(FloatBuffer storeBuffer)
      Write the 3x3 matrix in single precision to the specified buffer in column-major order and advance the buffer's position by 9. The matrix is unaffected.
      Specified by:
      put3x3ColumnMajor in interface RMat44Arg
      Parameters:
      storeBuffer - the destination buffer (not null)
    • putColumnMajor

      public void putColumnMajor(FloatBuffer storeBuffer)
      Write all 16 components in single precision to the specified buffer in column-major order and advance the buffer's position by 16. The matrix is unaffected.
      Specified by:
      putColumnMajor in interface RMat44Arg
      Parameters:
      storeBuffer - the destination buffer (not null)
    • toMat44

      public Mat44 toMat44()
      Copy the current matrix to a new, single-precision matrix. The current matrix is unaffected.
      Specified by:
      toMat44 in interface RMat44Arg
      Returns:
      the new matrix
    • toString

      public String toString()
      Return a string representation of the matrix, which is unaffected. For example, an identity matrix is represented by:
       RMat44[
        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)