Class MatrixNd

    • Field Detail

      • 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 Detail

      • 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 Detail

      • size

        public int size()
      • get

        public double get​(int row,
                          int col)
        Specified by:
        get 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)
      • mul

        public MatrixNd mul​(float a)
      • div

        public MatrixNd div​(float a)
      • pow

        public MatrixNd pow​(float pow)
      • translate

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

        public MatrixNd scale​(double... v)
      • transform

        public VectorNd transform​(double... vec)
      • trace

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

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

        public Matrix2d toMatrix2()
      • toMatrix3

        public Matrix3d toMatrix3()
      • toMatrix4

        public Matrix4d toMatrix4()
      • toArray

        public double[] toArray()
      • toArray

        public double[] toArray​(boolean columnMajor)
        Specified by:
        toArray in interface Matrixd
      • hashCode

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

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

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

        public static MatrixNd createRotation​(int size,
                                              Complexd 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