java.lang.Object
com.io7m.jtensors.core.unparameterized.matrices.Matrices4x4F

public final class Matrices4x4F
extends java.lang.Object

Functions over Matrix4x4F values.

See "Mathematics for 3D Game Programming and Computer Graphics" 2nd Ed for the derivations of most of the code in this class (ISBN: 1-58450-277-0).

Since:
8.0.0
  • Method Details

    • add

      public static Matrix4x4F add​(Matrix4x4F m0, Matrix4x4F m1)
      Add the matrices m0 and m1.
      Parameters:
      m0 - The left matrix
      m1 - The right matrix
      Returns:
      m0 + m1
    • determinant

      public static double determinant​(Matrix4x4F m)
      Calculate the determinant of the matrix m.
      Parameters:
      m - The matrix
      Returns:
      The determinant of m
    • invert

      public static java.util.Optional<Matrix4x4F> invert​(Matrix4x4F m)
      Calculate the inverse of the matrix m.
      Parameters:
      m - The matrix
      Returns:
      The inverse of m, or nothing if no inverse exists
    • multiply

      public static Matrix4x4F multiply​(Matrix4x4F m0, Matrix4x4F m1)
      Multiply the matrices m0 and m1.
      Parameters:
      m0 - The left matrix
      m1 - The right matrix
      Returns:
      m0 * m1
    • multiplyVectorPost

      public static Vector4F multiplyVectorPost​(Matrix4x4F m, Vector4F v)

      Multiply the vector v by the matrix m.

      This is post multiplication.

      Parameters:
      m - The matrix
      v - The vector
      Returns:
      m * v
    • ofColumns

      public static Matrix4x4F ofColumns​(Vector4F c0, Vector4F c1, Vector4F c2, Vector4F c3)
      Construct a matrix from the column vectors (c0, c1, c2, c3).
      Parameters:
      c0 - The column 0
      c1 - The column 1
      c2 - The column 2
      c3 - The column 3
      Returns:
      A constructed matrix
    • ofRows

      public static Matrix4x4F ofRows​(Vector4F r0, Vector4F r1, Vector4F r2, Vector4F r3)
      Construct a matrix from the row vectors (r0, r1, r2, r3).
      Parameters:
      r0 - The row 0
      r1 - The row 1
      r2 - The row 2
      r3 - The row 3
      Returns:
      A constructed matrix
    • ofScale

      public static Matrix4x4F ofScale​(double x, double y, double z)
      Construct a matrix that will scale by (x, y, z).
      Parameters:
      x - The X scaling value
      y - The Y scaling value
      z - The Z scaling value
      Returns:
      A constructed matrix
    • ofTranslation

      public static Matrix4x4F ofTranslation​(double x, double y, double z)
      Construct a matrix that will translate by (x, y, z).
      Parameters:
      x - The X scaling value
      y - The Y scaling value
      z - The Z scaling value
      Returns:
      A constructed matrix
    • ofAxisAngle

      public static Matrix4x4F ofAxisAngle​(double axis_x, double axis_y, double axis_z, double angle)
      Construct a matrix that will rotate by angle radians around the axis (x, y, z).
      Parameters:
      angle - The angle in radians
      axis_x - The X axis value
      axis_y - The Y axis value
      axis_z - The Z axis value
      Returns:
      A constructed matrix
    • row0

      public static Vector4F row0​(Matrix4x4F m)
      Parameters:
      m - The matrix
      Returns:
      Row 0 of the matrix
    • row1

      public static Vector4F row1​(Matrix4x4F m)
      Parameters:
      m - The matrix
      Returns:
      Row 1 of the matrix
    • row2

      public static Vector4F row2​(Matrix4x4F m)
      Parameters:
      m - The matrix
      Returns:
      Row 2 of the matrix
    • row3

      public static Vector4F row3​(Matrix4x4F m)
      Parameters:
      m - The matrix
      Returns:
      Row 3 of the matrix
    • column0

      public static Vector4F column0​(Matrix4x4F m)
      Parameters:
      m - The matrix
      Returns:
      Column 0 of the matrix
    • column1

      public static Vector4F column1​(Matrix4x4F m)
      Parameters:
      m - The matrix
      Returns:
      Column 1 of the matrix
    • column2

      public static Vector4F column2​(Matrix4x4F m)
      Parameters:
      m - The matrix
      Returns:
      Column 2 of the matrix
    • column3

      public static Vector4F column3​(Matrix4x4F m)
      Parameters:
      m - The matrix
      Returns:
      Column 3 of the matrix
    • scale

      public static Matrix4x4F scale​(Matrix4x4F m, double r)
      Scale the matrix m by r.
      Parameters:
      m - The matrix
      r - The scale factor
      Returns:
      m * r
    • subtract

      public static Matrix4x4F subtract​(Matrix4x4F m0, Matrix4x4F m1)
      Subtract the matrices m0 and m1.
      Parameters:
      m0 - The left matrix
      m1 - The right matrix
      Returns:
      m0 - m1
    • trace

      public static double trace​(Matrix4x4F m)
      Return the trace of the matrix m. The trace is defined as the sum of the diagonal elements of the matrix.
      Parameters:
      m - The matrix
      Returns:
      The trace of the matrix
    • transpose

      public static Matrix4x4F transpose​(Matrix4x4F m)
      Calculate the transpose of the matrix m.
      Parameters:
      m - The matrix
      Returns:
      The transpose of m
    • withColumn

      public static Matrix4x4F withColumn​(Matrix4x4F m, int column, float r0, float r1, float r2, float r3)
      Set the column column of m to (r0, r1, r2, r3).
      Parameters:
      m - The matrix
      column - The column index in the range [0, 3] * @param r0 The value of row 0 in the column
      r1 - The value of row 1 in the column
      r2 - The value of row 2 in the column
      r3 - The value of row 3 in the column
      Returns:
      A matrix with the given row
    • withRow

      public static Matrix4x4F withRow​(Matrix4x4F m, int row, float c0, float c1, float c2, float c3)
      Set the row row of m to (c0, c1, c2, c3).
      Parameters:
      m - The matrix
      row - The row index in the range [0, 3]
      c0 - The value of column 0 in the row
      c1 - The value of column 1 in the row
      c2 - The value of column 2 in the row
      c3 - The value of column 3 in the row
      Returns:
      A matrix with the given row
    • zero

      public static Matrix4x4F zero()
      The zero matrix.
      Returns:
      A matrix with all zero components
    • identity

      public static Matrix4x4F identity()
      The identity matrix.
      Returns:
      A matrix with all diagonal components set to 1 and all other components set to 0.