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

public final class Matrices2x2F
extends java.lang.Object

Functions over Matrix2x2F 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 Matrix2x2F add​(Matrix2x2F m0, Matrix2x2F m1)
      Add the matrices m0 and m1.
      Parameters:
      m0 - The left matrix
      m1 - The right matrix
      Returns:
      m0 + m1
    • determinant

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

      public static java.util.Optional<Matrix2x2F> invert​(Matrix2x2F 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 Matrix2x2F multiply​(Matrix2x2F m0, Matrix2x2F m1)
      Multiply the matrices m0 and m1.
      Parameters:
      m0 - The left matrix
      m1 - The right matrix
      Returns:
      m0 * m1
    • multiplyVectorPost

      public static Vector2F multiplyVectorPost​(Matrix2x2F m, Vector2F 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 Matrix2x2F ofColumns​(Vector2F c0, Vector2F c1)
      Construct a matrix from the column vectors (c0, c1).
      Parameters:
      c0 - The column 0
      c1 - The column 1
      Returns:
      A constructed matrix
    • ofRows

      public static Matrix2x2F ofRows​(Vector2F r0, Vector2F r1)
      Construct a matrix from the row vectors (r0, r1).
      Parameters:
      r0 - The row 0
      r1 - The row 1
      Returns:
      A constructed matrix
    • ofScale

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

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

      public static Vector2F row1​(Matrix2x2F m)
      Parameters:
      m - The matrix
      Returns:
      Row 1 of the matrix
    • column0

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

      public static Vector2F column1​(Matrix2x2F m)
      Parameters:
      m - The matrix
      Returns:
      Column 1 of the matrix
    • scale

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

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

      public static double trace​(Matrix2x2F 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 Matrix2x2F transpose​(Matrix2x2F m)
      Calculate the transpose of the matrix m.
      Parameters:
      m - The matrix
      Returns:
      The transpose of m
    • withColumn

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

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

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

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