Class MatrixNf

java.lang.Object
org.spongepowered.math.matrix.MatrixNf
All Implemented Interfaces:
Serializable, Cloneable, Matrixf

public class MatrixNf extends Object implements Matrixf, Serializable, Cloneable
See Also:
  • Field Details

    • IDENTITY_2

      public static final MatrixNf IDENTITY_2
    • IDENTITY_3

      public static final MatrixNf IDENTITY_3
    • IDENTITY_4

      public static final MatrixNf IDENTITY_4
  • Constructor Details

    • MatrixNf

      public MatrixNf(int size)
    • MatrixNf

      public MatrixNf(Matrix2f m)
    • MatrixNf

      public MatrixNf(Matrix3f m)
    • MatrixNf

      public MatrixNf(Matrix4f m)
    • MatrixNf

      public MatrixNf(float... m)
    • MatrixNf

      public MatrixNf(MatrixNf m)
  • Method Details

    • size

      public int size()
    • get

      public float get(int row, int col)
      Specified by:
      get in interface Matrixf
    • row

      public VectorNf row(int row)
      Specified by:
      row in interface Matrixf
    • column

      public VectorNf column(int col)
      Specified by:
      column in interface Matrixf
    • set

      public void set(int row, int col, double val)
    • set

      public void set(int row, int col, float val)
    • setIdentity

      public final void setIdentity()
    • setZero

      public void setZero()
    • resize

      public MatrixNf resize(int size)
    • add

      public MatrixNf add(MatrixNf m)
    • sub

      public MatrixNf sub(MatrixNf m)
    • mul

      public MatrixNf mul(double a)
    • mul

      public MatrixNf mul(float a)
      Specified by:
      mul in interface Matrixf
    • mul

      public MatrixNf mul(MatrixNf m)
    • div

      public MatrixNf div(double a)
    • div

      public MatrixNf div(float a)
      Specified by:
      div in interface Matrixf
    • div

      public MatrixNf div(MatrixNf m)
    • pow

      public MatrixNf pow(double pow)
    • pow

      public MatrixNf pow(float pow)
      Specified by:
      pow in interface Matrixf
    • translate

      public MatrixNf translate(VectorNf v)
    • translate

      public MatrixNf translate(float... v)
    • scale

      public MatrixNf scale(VectorNf v)
    • scale

      public MatrixNf scale(float... v)
    • rotate

      public MatrixNf rotate(Complexf rot)
    • rotate

      public MatrixNf rotate(Quaternionf rot)
    • transform

      public VectorNf transform(VectorNf v)
    • transform

      public VectorNf transform(float... vec)
    • floor

      public MatrixNf floor()
      Specified by:
      floor in interface Matrixf
    • ceil

      public MatrixNf ceil()
      Specified by:
      ceil in interface Matrixf
    • round

      public MatrixNf round()
      Specified by:
      round in interface Matrixf
    • abs

      public MatrixNf abs()
      Specified by:
      abs in interface Matrixf
    • negate

      public MatrixNf negate()
      Specified by:
      negate in interface Matrixf
    • transpose

      public MatrixNf transpose()
      Specified by:
      transpose in interface Matrixf
    • trace

      public float trace()
      Specified by:
      trace in interface Matrixf
    • determinant

      public float determinant()
      Specified by:
      determinant in interface Matrixf
    • invert

      public MatrixNf invert()
      Specified by:
      invert in interface Matrixf
    • toMatrix2

      public Matrix2f toMatrix2()
    • toMatrix3

      public Matrix3f toMatrix3()
    • toMatrix4

      public Matrix4f toMatrix4()
    • toArray

      public float[] toArray()
    • toFloat

      public MatrixNf toFloat()
      Specified by:
      toFloat in interface Matrixf
    • toDouble

      public MatrixNd toDouble()
      Specified by:
      toDouble in interface Matrixf
    • toArray

      public float[] toArray(boolean columnMajor)
      Specified by:
      toArray in interface Matrixf
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone

      public MatrixNf clone()
      Overrides:
      clone in class Object
    • createScaling

      public static MatrixNf createScaling(VectorNf v)
    • createScaling

      public static MatrixNf createScaling(float... vec)
    • createTranslation

      public static MatrixNf createTranslation(VectorNf v)
    • createTranslation

      public static MatrixNf createTranslation(float... vec)
    • createRotation

      public static MatrixNf createRotation(int size, Complexf rot)
    • createRotation

      public static MatrixNf createRotation(int size, Quaternionf rot)
    • createLookAt

      public static MatrixNf createLookAt(int size, Vector3f eye, Vector3f at, Vector3f up)
      Creates a "look at" matrix for the given eye point.
      Parameters:
      size - The size of the matrix, minimum of 4
      eye - The position of the camera
      at - The point that the camera is looking at
      up - The "up" vector
      Returns:
      A rotational transform that corresponds to a camera looking at the given point
    • createPerspective

      public static MatrixNf createPerspective(int size, double fov, double aspect, double near, double far)
      Creates a perspective projection matrix with the given (x) FOV, aspect, near and far planes
      Parameters:
      size - The size of the matrix, minimum of 4
      fov - The field of view in the x direction
      aspect - The aspect ratio, usually width/height
      near - The near plane, cannot be 0
      far - the far plane, zFar cannot equal zNear
      Returns:
      A perspective projection matrix built from the given values
    • createPerspective

      public static MatrixNf createPerspective(int size, float fov, float aspect, float near, float far)
      Creates a perspective projection matrix with the given (x) FOV, aspect, near and far planes
      Parameters:
      size - The size of the matrix, minimum of 4
      fov - The field of view in the x direction
      aspect - The aspect ratio, usually width/height
      near - The near plane, cannot be 0
      far - the far plane, zFar cannot equal zNear
      Returns:
      A perspective projection matrix built from the given values
    • createOrthographic

      public static MatrixNf createOrthographic(int size, double right, double left, double top, double bottom, double near, double far)
      Creates an orthographic viewing frustum built from the provided values
      Parameters:
      size - The size of the matrix, minimum of 4
      right - the right most plane of the viewing frustum
      left - the left most plane of the viewing frustum
      top - the top plane of the viewing frustum
      bottom - the bottom plane of the viewing frustum
      near - the near plane of the viewing frustum
      far - the far plane of the viewing frustum
      Returns:
      A viewing frustum built from the provided values
    • createOrthographic

      public static MatrixNf createOrthographic(int size, float right, float left, float top, float bottom, float near, float far)
      Creates an orthographic viewing frustum built from the provided values
      Parameters:
      size - The size of the matrix, minimum of 4
      right - the right most plane of the viewing frustum
      left - the left most plane of the viewing frustum
      top - the top plane of the viewing frustum
      bottom - the bottom plane of the viewing frustum
      near - the near plane of the viewing frustum
      far - the far plane of the viewing frustum
      Returns:
      A viewing frustum built from the provided values