Class MatrixNd

java.lang.Object
org.spongepowered.math.matrix.MatrixNd
All Implemented Interfaces:
Serializable, Cloneable, Matrixd

public class MatrixNd extends Object implements Matrixd, Serializable, Cloneable
See Also:
  • Field Details

    • IDENTITY_2

      public static final MatrixNd IDENTITY_2
    • IDENTITY_3

      public static final MatrixNd IDENTITY_3
    • IDENTITY_4

      public static final MatrixNd IDENTITY_4
  • Constructor Details

    • MatrixNd

      public MatrixNd(int size)
    • MatrixNd

      public MatrixNd(Matrix2d m)
    • MatrixNd

      public MatrixNd(Matrix3d m)
    • MatrixNd

      public MatrixNd(Matrix4d m)
    • MatrixNd

      public MatrixNd(double... m)
    • MatrixNd

      public MatrixNd(MatrixNd m)
  • Method Details

    • size

      public int size()
    • get

      public double get(int row, int col)
      Specified by:
      get in interface Matrixd
    • row

      public VectorNd row(int row)
      Specified by:
      row in interface Matrixd
    • column

      public VectorNd column(int col)
      Specified by:
      column in interface Matrixd
    • set

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

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

      public final void setIdentity()
    • setZero

      public void setZero()
    • resize

      public MatrixNd resize(int size)
    • add

      public MatrixNd add(MatrixNd m)
    • sub

      public MatrixNd sub(MatrixNd m)
    • mul

      public MatrixNd mul(float a)
    • mul

      public MatrixNd mul(double a)
      Specified by:
      mul in interface Matrixd
    • mul

      public MatrixNd mul(MatrixNd m)
    • div

      public MatrixNd div(float a)
    • div

      public MatrixNd div(double a)
      Specified by:
      div in interface Matrixd
    • div

      public MatrixNd div(MatrixNd m)
    • pow

      public MatrixNd pow(float pow)
    • pow

      public MatrixNd pow(double pow)
      Specified by:
      pow in interface Matrixd
    • translate

      public MatrixNd translate(VectorNd v)
    • translate

      public MatrixNd translate(double... v)
    • scale

      public MatrixNd scale(VectorNd v)
    • scale

      public MatrixNd scale(double... v)
    • rotate

      public MatrixNd rotate(Complexd rot)
    • rotate

      public MatrixNd rotate(Quaterniond rot)
    • transform

      public VectorNd transform(VectorNd v)
    • transform

      public VectorNd transform(double... vec)
    • floor

      public MatrixNd floor()
      Specified by:
      floor in interface Matrixd
    • ceil

      public MatrixNd ceil()
      Specified by:
      ceil in interface Matrixd
    • round

      public MatrixNd round()
      Specified by:
      round in interface Matrixd
    • abs

      public MatrixNd abs()
      Specified by:
      abs in interface Matrixd
    • negate

      public MatrixNd negate()
      Specified by:
      negate in interface Matrixd
    • transpose

      public MatrixNd transpose()
      Specified by:
      transpose in interface Matrixd
    • trace

      public double trace()
      Specified by:
      trace in interface Matrixd
    • determinant

      public double determinant()
      Specified by:
      determinant in interface Matrixd
    • invert

      public MatrixNd invert()
      Specified by:
      invert in interface Matrixd
    • toMatrix2

      public Matrix2d toMatrix2()
    • toMatrix3

      public Matrix3d toMatrix3()
    • toMatrix4

      public Matrix4d toMatrix4()
    • toArray

      public double[] toArray()
    • toFloat

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

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

      public double[] toArray(boolean columnMajor)
      Specified by:
      toArray in interface Matrixd
    • 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 MatrixNd clone()
      Overrides:
      clone in class Object
    • createScaling

      public static MatrixNd createScaling(VectorNd v)
    • createScaling

      public static MatrixNd createScaling(double... vec)
    • createTranslation

      public static MatrixNd createTranslation(VectorNd v)
    • createTranslation

      public static MatrixNd createTranslation(double... vec)
    • createRotation

      public static MatrixNd createRotation(int size, Complexd rot)
    • createRotation

      public static MatrixNd createRotation(int size, Quaterniond rot)
    • createLookAt

      public static MatrixNd createLookAt(int size, Vector3d eye, Vector3d at, Vector3d 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 MatrixNd 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
    • createPerspective

      public static MatrixNd 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
    • createOrthographic

      public static MatrixNd 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
    • createOrthographic

      public static MatrixNd 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