Package com.jme3.math

Class Matrix4f

java.lang.Object
com.jme3.math.Matrix4f
All Implemented Interfaces:
Savable, Serializable, Cloneable

public final class Matrix4f extends Object implements Savable, Cloneable, Serializable
A 4x4 matrix composed of 16 single-precision elements, used to represent linear or perspective transformations of 3-D coordinates.

The rightmost column (column 3) stores the translation vector. Element numbering is (row,column), so m03 is the row 0, column 3, which is the X translation.

Methods with names ending in "Local" modify the current instance. They are used to avoid creating garbage.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Matrix4f
    an instance of the identity matrix (diagonals = 1, other elements = 0)
    float
    The element in row 0, column 0.
    float
    The element in row 0, column 1.
    float
    The element in row 0, column 2.
    float
    The element in row 0, column 3 (the X translation).
    float
    The element in row 1, column 0.
    float
    The element in row 1, column 1.
    float
    The element in row 1, column 2.
    float
    The element in row 1, column 3 (the Y translation).
    float
    The element in row 2, column 0.
    float
    The element in row 2, column 1.
    float
    The element in row 2, column 2.
    float
    The element in row 2, column 3 (the Z translation).
    float
    The element in row 3, column 0.
    float
    The element in row 3, column 1.
    float
    The element in row 3, column 2.
    float
    The element in row 3, column 3.
    static final Matrix4f
    an instance of the zero matrix (all elements = 0)
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiates an identity matrix (diagonals = 1, other elements = 0).
    Matrix4f(float[] array)
    Create a Matrix4f from the specified array.
    Matrix4f(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
    Create a Matrix4f with the specified element values.
    Create a Matrix4f that duplicates the specified matrix.
  • Method Summary

    Modifier and Type
    Method
    Description
    Add the specified matrix.
    void
    Sum in place, with the specified matrix.
    Generate the adjoint.
    Generate the adjoint.
    void
    Load a rotation around three axes (x, y, z).
    Creates a copy.
    void
    copy(Matrix4f matrix)
    Copy all elements of the specified matrix to this matrix.
    float
    Calculate the determinant.
    boolean
    Tests for exact equality with the argument, distinguishing -0 from 0.
    void
    fillFloatArray(float[] f, boolean columnMajor)
    Copy all elements to a float array.
    Copy all elements to an existing FloatBuffer, starting at its current position, in row-major order.
    fillFloatBuffer(FloatBuffer fb, boolean columnMajor)
    Copy all elements to an existing FloatBuffer, starting at its current position.
    void
    fromAngleAxis(float angle, Vector3f axis)
    Load a 3-D rotation specified by an angle and axis.
    void
    fromAngleNormalAxis(float angle, Vector3f axis)
    Load a 3-D rotation specified by an angle and axis.
    void
    fromFrame(Vector3f location, Vector3f direction, Vector3f up, Vector3f left)
     
    void
    fromFrustum(float near, float far, float left, float right, float top, float bottom, boolean parallel)
    Load a perspective-view transform with the specified clipping planes.
    void
    get(float[] matrix)
    Copy all elements to a float array, in row-major order.
    void
    get(float[] matrix, boolean rowMajor)
    Copy all elements to a float array.
    float
    get(int i, int j)
    Retrieve the element at the specified position.
    float[]
    getColumn(int i)
    Copy the specified column to a new float array.
    float[]
    getColumn(int i, float[] store)
    Copy the specified column to a float array.
    int
    Returns a hash code.
    void
    Inverse rotate the specified Vector3f using the rotation component of this 3-D coordinate transform.
    void
    inverseTranslateVect(float[] vec)
    Inverse translate the specified vector using the translation component of this 3-D coordinate transform.
    void
    Inverse translate the specified Vector3f using the translation component of this 3-D coordinate transform.
    Generate the inverse.
    Generate the inverse.
    Inverts in place.
    boolean
    Test for exact identity.
    void
    Configures as an identity matrix (diagonals = 1, other elements = 0).
    mult(float scalar)
    Multiply by the specified scalar.
    float[]
    mult(float[] vec4f)
    Multiply the specified float array by this matrix.
    mult(float scalar, Matrix4f store)
    Multiply by the specified scalar.
    Right-multiply by the specified matrix.
    mult(Matrix4f in2, Matrix4f store)
    Right-multiply by the specified matrix.
    mult(Quaternion vec, Quaternion store)
    Multiply the specified Quaternion by this matrix.
    Apply this 3-D coordinate transform to the specified Vector3f.
    mult(Vector3f vec, Vector3f store)
    Apply this 3-D coordinate transform to the specified Vector3f.
    Multiply the specified Vector4f by this matrix.
    mult(Vector4f vec, Vector4f store)
    Multiply the specified Vector4f by this matrix.
    float[]
    multAcross(float[] vec4f)
    Multiply the specified float array by the transform of this matrix.
    Apply the transform of this 3-D coordinate transform to the specified Vector3f.
    Multiply the specified Vector4f by the transform of this matrix.
    Multiply the specified Vector4f by the transform of this matrix.
    void
    multLocal(float scalar)
    Multiplies in place by the scalar argument.
    Right-multiply in place, by the specified matrix.
    void
     
    Rotate and scale the specified vector, but don't translate it.
    Rotate and scale the specified vector by the transpose, but don't translate it.
    float
    multProj(Vector3f vec, Vector3f store)
    Apply this perspective transform to the specified Vector3f.
    void
    read(JmeImporter importer)
    De-serialize from the specified importer, for example when loading from a J3O file.
    Load from the specified FloatBuffer, in row-major order.
    readFloatBuffer(FloatBuffer fb, boolean columnMajor)
    Load from the specified FloatBuffer.
    void
    Rotate the specified Vector3f using the rotation component of this 3-D coordinate transform.
    void
    scale(Vector3f scale)
    Scale by the specified Vector3f.
    void
    set(float[] matrix)
    Load all elements from the specified array.
    void
    set(float[][] matrix)
    Load all elements from the specified 4x4 array.
    void
    set(float[] matrix, boolean rowMajor)
    Load all elements from the specified array.
    void
    set(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
    Load the specified element values.
    void
    set(int i, int j, float value)
    Store the specified value at the specified position.
    set(Matrix4f matrix)
    Copy all elements of the specified matrix to this matrix.
    void
    setColumn(int i, float[] column)
    Load the specified column from the specified array.
    void
    setInverseRotationDegrees(float[] angles)
    Load an inverted rotation from Euler angles in degrees.
    void
    setInverseRotationRadians(float[] angles)
    Load an inverted rotation from Euler angles in radians.
    void
    setInverseTranslation(float[] translation)
    Alter the inverse-translation component of this 3-D coordinate transform.
    void
    Load a rotation from a Quaternion.
    void
    setScale(float x, float y, float z)
    Alters the scale component of the coordinate transform.
    void
    Alters the scale component of the coordinate transform.
    void
    setTransform(Vector3f position, Vector3f scale, Matrix3f rotMat)
    Load with the specified coordinate transform.
    void
    setTranslation(float[] translation)
    Alter the translation component of this 3-D coordinate transform.
    void
    setTranslation(float x, float y, float z)
    Alter the translation component of this 3-D coordinate transform.
    void
    setTranslation(Vector3f translation)
    Alters the translation component of the coordinate transform.
    Copy all elements to a new, direct FloatBuffer.
    toFloatBuffer(boolean columnMajor)
    Copy all elements to a new, direct FloatBuffer.
    Determine the rotation component of this 3-D coordinate transform.
    void
    Determines the rotation component of the coordinate transform.
    Determine the rotation component of this 3-D coordinate transform.
    Returns the rotation component of the coordinate transform.
    Determine the scale component of this 3-D coordinate transform.
    Determines the scale component of the coordinate transform.
    Returns a string representation of the matrix, which is unaffected.
    Determine the translation component of this 3-D coordinate transform.
    Returns the translation component of the coordinate transform.
    void
    Translate the specified Vector3f using the translation component of this 3-D coordinate transform.
    Generate the transpose.
    Transpose in place.
    void
    Serialize to the specified exporter, for example when saving to a J3O file.
    Sets all elements to zero.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • m00

      public float m00
      The element in row 0, column 0.
    • m01

      public float m01
      The element in row 0, column 1.
    • m02

      public float m02
      The element in row 0, column 2.
    • m03

      public float m03
      The element in row 0, column 3 (the X translation).
    • m10

      public float m10
      The element in row 1, column 0.
    • m11

      public float m11
      The element in row 1, column 1.
    • m12

      public float m12
      The element in row 1, column 2.
    • m13

      public float m13
      The element in row 1, column 3 (the Y translation).
    • m20

      public float m20
      The element in row 2, column 0.
    • m21

      public float m21
      The element in row 2, column 1.
    • m22

      public float m22
      The element in row 2, column 2.
    • m23

      public float m23
      The element in row 2, column 3 (the Z translation).
    • m30

      public float m30
      The element in row 3, column 0.
    • m31

      public float m31
      The element in row 3, column 1.
    • m32

      public float m32
      The element in row 3, column 2.
    • m33

      public float m33
      The element in row 3, column 3.
    • ZERO

      public static final Matrix4f ZERO
      an instance of the zero matrix (all elements = 0)
    • IDENTITY

      public static final Matrix4f IDENTITY
      an instance of the identity matrix (diagonals = 1, other elements = 0)
  • Constructor Details

    • Matrix4f

      public Matrix4f()
      Instantiates an identity matrix (diagonals = 1, other elements = 0).
    • Matrix4f

      public Matrix4f(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
      Create a Matrix4f with the specified element values.
      Parameters:
      m00 - the desired value for row 0, column 0
      m01 - the desired value for row 0, column 1
      m02 - the desired value for row 0, column 2
      m03 - the desired value for row 0, column 3
      m10 - the desired value for row 1, column 0
      m11 - the desired value for row 1, column 1
      m12 - the desired value for row 1, column 2
      m13 - the desired value for row 1, column 3
      m20 - the desired value for row 2, column 0
      m21 - the desired value for row 2, column 1
      m22 - the desired value for row 2, column 2
      m23 - the desired value for row 2, column 3
      m30 - the desired value for row 3, column 0
      m31 - the desired value for row 3, column 1
      m32 - the desired value for row 3, column 2
      m33 - the desired value for row 3, column 3
    • Matrix4f

      public Matrix4f(float[] array)
      Create a Matrix4f from the specified array.
      Parameters:
      array - the source array: 16 floats in column-major order (translation in elements 12, 13, and 14)
    • Matrix4f

      public Matrix4f(Matrix4f mat)
      Create a Matrix4f that duplicates the specified matrix. If null is specified, the new matrix is initialized to identity (diagonals = 1, other elements = 0).
      Parameters:
      mat - the source matrix (unaffected, may be null)
  • Method Details

    • copy

      public void copy(Matrix4f matrix)
      Copy all elements of the specified matrix to this matrix. If null is specified, load identity (diagonals = 1, other elements = 0).
      Parameters:
      matrix - the source matrix (may be null, unaffected)
    • fromFrame

      public void fromFrame(Vector3f location, Vector3f direction, Vector3f up, Vector3f left)
    • get

      public void get(float[] matrix)
      Copy all elements to a float array, in row-major order.
      Parameters:
      matrix - the destination array (not null, length=16)
    • get

      public void get(float[] matrix, boolean rowMajor)
      Copy all elements to a float array.
      Parameters:
      matrix - the destination array (not null, length=16)
      rowMajor - true to store in row-major order, false to store in column-major order
    • get

      public float get(int i, int j)
      Retrieve the element at the specified position.
      Parameters:
      i - the row index of the element to retrieve (0, 1, 2, or 3)
      j - the column index of the element to retrieve (0, 1, 2, or 3)
      Returns:
      the value at (i, j)
      Throws:
      IllegalArgumentException - if either index is invalid.
    • getColumn

      public float[] getColumn(int i)
      Copy the specified column to a new float array.
      Parameters:
      i - the index of the column to copy (0, 1, 2, or 3)
      Returns:
      a new array with length=4
    • getColumn

      public float[] getColumn(int i, float[] store)
      Copy the specified column to a float array.
      Parameters:
      i - the index of the column to copy (0, 1, 2, or 3)
      store - storage for the result (modified) or null to create a new array
      Returns:
      either store or a new array with length=4
    • setColumn

      public void setColumn(int i, float[] column)
      Load the specified column from the specified array.
      Parameters:
      i - the index of the column to fill (0, 1, 2, or 3)
      column - the source array (unaffected) or null
    • set

      public void set(int i, int j, float value)
      Store the specified value at the specified position.
      Parameters:
      i - the row index of the element to set (0, 1, 2, or 3)
      j - the column index of the element to set (0, 1, 2, or 3)
      value - the value for element (i, j)
      Throws:
      IllegalArgumentException - if either index is invalid.
    • set

      public void set(float[][] matrix)
      Load all elements from the specified 4x4 array.
      Parameters:
      matrix - the source array (not null, unaffected)
      Throws:
      IllegalArgumentException - if the source array isn't 4x4.
    • set

      public void set(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
      Load the specified element values.
      Parameters:
      m00 - the desired value for row 0, column 0
      m01 - the desired value for row 0, column 1
      m02 - the desired value for row 0, column 2
      m03 - the desired value for row 0, column 3
      m10 - the desired value for row 1, column 0
      m11 - the desired value for row 1, column 1
      m12 - the desired value for row 1, column 2
      m13 - the desired value for row 1, column 3
      m20 - the desired value for row 2, column 0
      m21 - the desired value for row 2, column 1
      m22 - the desired value for row 2, column 2
      m23 - the desired value for row 2, column 3
      m30 - the desired value for row 3, column 0
      m31 - the desired value for row 3, column 1
      m32 - the desired value for row 3, column 2
      m33 - the desired value for row 3, column 3
    • set

      public Matrix4f set(Matrix4f matrix)
      Copy all elements of the specified matrix to this matrix.
      Parameters:
      matrix - the source matrix (not null, unaffected)
      Returns:
      this (modified)
    • set

      public void set(float[] matrix)
      Load all elements from the specified array.
      Parameters:
      matrix - the source array, in row-major order (not null, length=16, unaffected)
    • set

      public void set(float[] matrix, boolean rowMajor)
      Load all elements from the specified array.
      Parameters:
      matrix - the source array (not null, length=16, unaffected)
      rowMajor - true if the source array is in row-major order, false if it's in column-major order
    • transpose

      public Matrix4f transpose()
      Generate the transpose.
      Returns:
      a new Matrix4f with the rows and columns transposed
    • transposeLocal

      public Matrix4f transposeLocal()
      Transpose in place.
      Returns:
      this (transposed)
    • toFloatBuffer

      public FloatBuffer toFloatBuffer()
      Copy all elements to a new, direct FloatBuffer.
      Returns:
      a rewound buffer containing all 16 element values in row-major order
    • toFloatBuffer

      public FloatBuffer toFloatBuffer(boolean columnMajor)
      Copy all elements to a new, direct FloatBuffer.
      Parameters:
      columnMajor - true to store in column-major order, false to store in row-major order
      Returns:
      a rewound buffer containing all 16 element values
    • fillFloatBuffer

      public FloatBuffer fillFloatBuffer(FloatBuffer fb)
      Copy all elements to an existing FloatBuffer, starting at its current position, in row-major order.
      Parameters:
      fb - the destination buffer (not null, must have space remaining for 16 floats)
      Returns:
      the destination buffer, its position advanced by 16
    • fillFloatBuffer

      public FloatBuffer fillFloatBuffer(FloatBuffer fb, boolean columnMajor)
      Copy all elements to an existing FloatBuffer, starting at its current position.
      Parameters:
      fb - the destination buffer (not null, must have space remaining for 16 floats)
      columnMajor - true to store in column-major order, false to store in row-major order
      Returns:
      the destination buffer, its position advanced by 16
    • fillFloatArray

      public void fillFloatArray(float[] f, boolean columnMajor)
      Copy all elements to a float array.
      Parameters:
      f - the destination array (not null, length≥16, modified)
      columnMajor - true → column-major order, false → row-major order
    • readFloatBuffer

      public Matrix4f readFloatBuffer(FloatBuffer fb)
      Load from the specified FloatBuffer, in row-major order.
      Parameters:
      fb - the source buffer, must have 16 floats remaining to get
      Returns:
      this (modified)
    • readFloatBuffer

      public Matrix4f readFloatBuffer(FloatBuffer fb, boolean columnMajor)
      Load from the specified FloatBuffer.
      Parameters:
      fb - the source buffer, must have 16 floats remaining to get
      columnMajor - if true, the buffer contains column-major data, otherwise it contains row-major data.
      Returns:
      this (modified)
    • loadIdentity

      public void loadIdentity()
      Configures as an identity matrix (diagonals = 1, other elements = 0).
    • fromFrustum

      public void fromFrustum(float near, float far, float left, float right, float top, float bottom, boolean parallel)
      Load a perspective-view transform with the specified clipping planes.
      Parameters:
      near - the coordinate of the near plane
      far - the coordinate of the far plane
      left - the coordinate of the left plane
      right - the coordinate of the right plane
      top - the coordinate of the top plane
      bottom - the coordinate of the bottom plane
      parallel - true → parallel sides, false → perspective
    • fromAngleAxis

      public void fromAngleAxis(float angle, Vector3f axis)
      Load a 3-D rotation specified by an angle and axis. If the axis is already normalized, use fromAngleNormalAxis(float, com.jme3.math.Vector3f) instead because it's more efficient.
      Parameters:
      angle - the angle to rotate (in radians)
      axis - the axis of rotation (not null)
    • fromAngleNormalAxis

      public void fromAngleNormalAxis(float angle, Vector3f axis)
      Load a 3-D rotation specified by an angle and axis. Assumes the axis is already normalized.
      Parameters:
      angle - the angle to rotate (in radians)
      axis - the axis of rotation (not null, already normalized)
    • multLocal

      public void multLocal(float scalar)
      Multiplies in place by the scalar argument.
      Parameters:
      scalar - the scaling factor to apply to all elements
    • mult

      public Matrix4f mult(float scalar)
      Multiply by the specified scalar.
      Parameters:
      scalar - the scale factor to apply to all elements
      Returns:
      a new Matrix4f with every element scaled
    • mult

      public Matrix4f mult(float scalar, Matrix4f store)
      Multiply by the specified scalar.
      Parameters:
      scalar - the scale factor to apply to all elements
      store - storage for the result (modified) or null to create a new matrix
      Returns:
      a scaled matrix (either store or a new instance)
    • mult

      public Matrix4f mult(Matrix4f in2)
      Right-multiply by the specified matrix. (This matrix is the left factor.)
      Parameters:
      in2 - the right factor (not null, unaffected)
      Returns:
      the product, this times in2 (a new instance)
    • mult

      public Matrix4f mult(Matrix4f in2, Matrix4f store)
      Right-multiply by the specified matrix. (This matrix is the left factor.)
      Parameters:
      in2 - the right factor (not null)
      store - storage for the result (modified) or null to create a new matrix. It is safe for in2 and store to be the same object.
      Returns:
      the product, this times in2 (either store or a new instance)
    • multLocal

      public Matrix4f multLocal(Matrix4f in2)
      Right-multiply in place, by the specified matrix. (This matrix is the left factor.)
      Parameters:
      in2 - the right factor (not null)
      Returns:
      this (modified)
    • mult

      public Vector3f mult(Vector3f vec)
      Apply this 3-D coordinate transform to the specified Vector3f.
      Parameters:
      vec - the vector to transform (not null)
      Returns:
      a new vector
    • mult

      public Vector3f mult(Vector3f vec, Vector3f store)
      Apply this 3-D coordinate transform to the specified Vector3f.
      Parameters:
      vec - the vector to transform (not null)
      store - storage for the result (modified) or null to create a new vector
      Returns:
      the transformed vector (either store or a new vector)
    • mult

      public Vector4f mult(Vector4f vec)
      Multiply the specified Vector4f by this matrix.
      Parameters:
      vec - the vector to multiply (unaffected) or null
      Returns:
      a new vector or null
    • mult

      public Vector4f mult(Vector4f vec, Vector4f store)
      Multiply the specified Vector4f by this matrix.
      Parameters:
      vec - the vector to multiply (unaffected) or null
      store - storage for the result (modified) or null to create a new vector
      Returns:
      the product (either store or a new vector) or null
    • multAcross

      public Vector4f multAcross(Vector4f vec)
      Multiply the specified Vector4f by the transform of this matrix.
      Parameters:
      vec - the vector to multiply (unaffected) or null
      Returns:
      a new vector or null
    • multAcross

      public Vector4f multAcross(Vector4f vec, Vector4f store)
      Multiply the specified Vector4f by the transform of this matrix.
      Parameters:
      vec - the vector to multiply (unaffected) or null
      store - storage for the result (modified) or null to create a new vector
      Returns:
      the product (either store or a new vector) or null
    • multNormal

      public Vector3f multNormal(Vector3f vec, Vector3f store)
      Rotate and scale the specified vector, but don't translate it.
      Parameters:
      vec - the vector to transform (not null, unaffected)
      store - storage for the result (modified) or null to create a new vector
      Returns:
      the transformed vector (either store or a new vector)
    • multNormalAcross

      public Vector3f multNormalAcross(Vector3f vec, Vector3f store)
      Rotate and scale the specified vector by the transpose, but don't translate it.
      Parameters:
      vec - the vector to transform (not null, unaffected)
      store - storage for the result (modified) or null to create a new vector
      Returns:
      the transformed vector (either store or a new vector)
    • multProj

      public float multProj(Vector3f vec, Vector3f store)
      Apply this perspective transform to the specified Vector3f. Return the W value, calculated by dotting the vector with the last row.
      Parameters:
      vec - the vector to transform (not null, unaffected)
      store - storage for the result (not null, modified)
      Returns:
      the W value
    • multAcross

      public Vector3f multAcross(Vector3f vec, Vector3f store)
      Apply the transform of this 3-D coordinate transform to the specified Vector3f.
      Parameters:
      vec - the vector to transform (unaffected) or null
      store - storage for the result (modified) or null to create a new vector
      Returns:
      the transformed vector (either store or a new vector) or null
    • mult

      public Quaternion mult(Quaternion vec, Quaternion store)
      Multiply the specified Quaternion by this matrix.
      Parameters:
      vec - the Quaternion to multiply (unaffected) or null
      store - storage for the result (modified) or null to create a new Quaternion
      Returns:
      the product (either store or a new Quaternion) or null
    • mult

      public float[] mult(float[] vec4f)
      Multiply the specified float array by this matrix.
      Parameters:
      vec4f - the array to multiply or null
      Returns:
      vec4f (modified) or null
    • multAcross

      public float[] multAcross(float[] vec4f)
      Multiply the specified float array by the transform of this matrix.
      Parameters:
      vec4f - the array to multiply or null
      Returns:
      vec4f (modified) or null
    • invert

      public Matrix4f invert()
      Generate the inverse.
      Returns:
      a new instance
    • invert

      public Matrix4f invert(Matrix4f store)
      Generate the inverse.
      Parameters:
      store - storage for the result (modified) or null to create a new matrix
      Returns:
      either store or a new instance
      Throws:
      ArithmeticException - if cannot be inverted
    • invertLocal

      public Matrix4f invertLocal()
      Inverts in place. If the current instance is singular, the matrix is zeroed.
      Returns:
      the (inverted) current instance (for chaining)
    • adjoint

      public Matrix4f adjoint()
      Generate the adjoint.
      Returns:
      a new instance
    • setTransform

      public void setTransform(Vector3f position, Vector3f scale, Matrix3f rotMat)
      Load with the specified coordinate transform. The effective sequence of operations is: scale, then rotate, then translate.
      Parameters:
      position - the desired translation (not null, unaffected)
      scale - the desired scale factors (not null, unaffected)
      rotMat - the desired rotation (not null, unaffected)
    • adjoint

      public Matrix4f adjoint(Matrix4f store)
      Generate the adjoint.
      Parameters:
      store - storage for the result (modified) or null to create a new matrix
      Returns:
      either store or a new instance
    • determinant

      public float determinant()
      Calculate the determinant.
      Returns:
      the determinant
    • zero

      public Matrix4f zero()
      Sets all elements to zero.
      Returns:
      the (modified) current instance (for chaining)
    • add

      public Matrix4f add(Matrix4f mat)
      Add the specified matrix.
      Parameters:
      mat - the matrix to add (not null)
      Returns:
      the sum (a new instance)
    • addLocal

      public void addLocal(Matrix4f mat)
      Sum in place, with the specified matrix.
      Parameters:
      mat - the matrix to add (not null)
    • toTranslationVector

      public Vector3f toTranslationVector()
      Determine the translation component of this 3-D coordinate transform.
      Returns:
      a new translation vector
    • toTranslationVector

      public Vector3f toTranslationVector(Vector3f vector)
      Returns the translation component of the coordinate transform.
      Parameters:
      vector - storage for the result (not null, modified)
      Returns:
      the translation component (in vector) for chaining
    • toRotationQuat

      public Quaternion toRotationQuat()
      Determine the rotation component of this 3-D coordinate transform.
      Returns:
      a new rotation Quaternion
    • toRotationQuat

      public Quaternion toRotationQuat(Quaternion q)
      Returns the rotation component of the coordinate transform.
      Parameters:
      q - storage for the result (not null, modified)
      Returns:
      the rotation component (in q) for chaining
    • toRotationMatrix

      public Matrix3f toRotationMatrix()
      Determine the rotation component of this 3-D coordinate transform.
      Returns:
      a new rotation Matrix3f
    • toRotationMatrix

      public void toRotationMatrix(Matrix3f mat)
      Determines the rotation component of the coordinate transform.
      Parameters:
      mat - storage for the result (not null, modified)
    • toScaleVector

      public Vector3f toScaleVector()
      Determine the scale component of this 3-D coordinate transform.
      Returns:
      a new Vector3f
    • toScaleVector

      public Vector3f toScaleVector(Vector3f store)
      Determines the scale component of the coordinate transform.
      Parameters:
      store - storage for the result (not null, modified)
      Returns:
      the scale factors (in store) for chaining
    • setScale

      public void setScale(float x, float y, float z)
      Alters the scale component of the coordinate transform.
      Parameters:
      x - the desired scale factor for the X axis
      y - the desired scale factor for the Y axis
      z - the desired scale factor for the Z axis
    • setScale

      public void setScale(Vector3f scale)
      Alters the scale component of the coordinate transform.
      Parameters:
      scale - the desired scale factors (not null, unaffected)
    • setTranslation

      public void setTranslation(float[] translation)
      Alter the translation component of this 3-D coordinate transform.
      Parameters:
      translation - the desired translation (not null, length=3, unaffected)
      Throws:
      IllegalArgumentException - if translation doesn't have length=3.
    • setTranslation

      public void setTranslation(float x, float y, float z)
      Alter the translation component of this 3-D coordinate transform.
      Parameters:
      x - the desired X-axis offset
      y - the desired Y-axis offset
      z - the desired Z-axis offset
    • setTranslation

      public void setTranslation(Vector3f translation)
      Alters the translation component of the coordinate transform.
      Parameters:
      translation - the desired translation (not null, unaffected)
    • setInverseTranslation

      public void setInverseTranslation(float[] translation)
      Alter the inverse-translation component of this 3-D coordinate transform.
      Parameters:
      translation - the desired inverse translation (not null, length=3, unaffected)
      Throws:
      IllegalArgumentException - if translation doesn't have length=3.
    • angleRotation

      public void angleRotation(Vector3f angles)
      Load a rotation around three axes (x, y, z). Where each axis has a specified rotation in degrees. These rotations are expressed in a single Vector3f object.
      Parameters:
      angles - the desired rotation angles for each axis (in degrees)
    • setRotationQuaternion

      public void setRotationQuaternion(Quaternion quat)
      Load a rotation from a Quaternion.
      Parameters:
      quat - the desired rotation (not null, unaffected)
      Throws:
      NullPointerException - if quat is null.
    • setInverseRotationRadians

      public void setInverseRotationRadians(float[] angles)
      Load an inverted rotation from Euler angles in radians.
      Parameters:
      angles - the desired Euler angles (in radians, not null, length=3)
      Throws:
      IllegalArgumentException - if angles doesn't have length=3.
    • setInverseRotationDegrees

      public void setInverseRotationDegrees(float[] angles)
      Load an inverted rotation from Euler angles in degrees.
      Parameters:
      angles - the desired Euler angles (in degrees, not null, length=3)
      Throws:
      IllegalArgumentException - if angles doesn't have length=3.
    • inverseTranslateVect

      public void inverseTranslateVect(float[] vec)
      Inverse translate the specified vector using the translation component of this 3-D coordinate transform.
      Parameters:
      vec - the vector to translate (not null, length=3, modified)
      Throws:
      IllegalArgumentException - if vec doesn't have length=3.
    • inverseTranslateVect

      public void inverseTranslateVect(Vector3f data)
      Inverse translate the specified Vector3f using the translation component of this 3-D coordinate transform.
      Parameters:
      data - the Vector3f to translate (not null, modified)
    • translateVect

      public void translateVect(Vector3f data)
      Translate the specified Vector3f using the translation component of this 3-D coordinate transform.
      Parameters:
      data - the Vector3f to translate (not null, modified)
    • inverseRotateVect

      public void inverseRotateVect(Vector3f vec)
      Inverse rotate the specified Vector3f using the rotation component of this 3-D coordinate transform.
      Parameters:
      vec - the Vector3f to inverse rotate (not null, modified)
    • rotateVect

      public void rotateVect(Vector3f vec)
      Rotate the specified Vector3f using the rotation component of this 3-D coordinate transform.
      Parameters:
      vec - the Vector3f to rotate (not null, modified)
    • toString

      public String toString()
      Returns a string representation of the matrix, which is unaffected. For example, the identity matrix is represented by:
       Matrix4f
       [
        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 Object
      Returns:
      the string representation (not null, not empty)
    • hashCode

      public int hashCode()
      Returns a hash code. If two matrices have identical values, they will have the same hash code. The matrix is unaffected.
      Overrides:
      hashCode in class Object
      Returns:
      a 32-bit value for use in hashing
      See Also:
    • equals

      public boolean equals(Object o)
      Tests for exact equality with the argument, distinguishing -0 from 0. If o is null, false is returned. Either way, the current instance is unaffected.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare (may be null, unaffected)
      Returns:
      true if this and o have identical values, otherwise false
    • write

      public void write(JmeExporter e) throws IOException
      Serialize to the specified exporter, for example when saving to a J3O file.
      Specified by:
      write in interface Savable
      Parameters:
      e - (not null)
      Throws:
      IOException - from the exporter
    • read

      public void read(JmeImporter importer) throws IOException
      De-serialize from the specified importer, for example when loading from a J3O file.
      Specified by:
      read in interface Savable
      Parameters:
      importer - (not null)
      Throws:
      IOException - from the importer
    • isIdentity

      public boolean isIdentity()
      Test for exact identity.
      Returns:
      true if this is an exact identity, otherwise false
    • scale

      public void scale(Vector3f scale)
      Scale by the specified Vector3f.
      Parameters:
      scale - the scale factors to apply
    • multLocal

      public void multLocal(Quaternion rotation)
    • clone

      public Matrix4f clone()
      Creates a copy. The current instance is unaffected.
      Overrides:
      clone in class Object
      Returns:
      a new instance with the same element values