Class GMatrixf

  • All Implemented Interfaces:
    java.io.Serializable

    public class GMatrixf
    extends java.lang.Object
    implements java.io.Serializable
    Matrix operations are applied on the left. For example, given a matrix M and a vector V, matrix-times-vector is M*V. That is, V is treated as a column vector. Some graphics APIs use V*M where V is treated as a row vector. In this context the "M" matrix is really a transpose of the M as represented in Wild Magic. Similarly, to apply two matrix operations M0 and M1, in that order, you compute M1*M0 so that the transform of a vector is (M1*M0)*V = M1*(M0*V). Some graphics APIs use M0*M1, but again these matrices are the transpose of those as represented in Wild Magic. You must therefore be careful about how you interface the transformation code with graphics APIS. Matrices are stored in row-major order, matrix[row][col].
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private float[] m_afData
      the matrix is stored in row-major form as a 1-dimensional array
      private int m_iCols
      rows, columns, and size:
      private int m_iQuantity
      rows, columns, and size:
      private int m_iRows
      rows, columns, and size:
      private static long serialVersionUID  
    • Constructor Summary

      Constructors 
      Constructor Description
      GMatrixf()
      Construct a general matrix of size 0,0.
      GMatrixf​(int iRows, int iCols)
      Construct a general matrix of size iRows,iCols.
      GMatrixf​(int iRows, int iCols, double[][] aafMatrix)
      Construct a general matrix of size iRows,iCols.
      GMatrixf​(int iRows, int iCols, float[] afEntry)
      Construct a general matrix of size iRows,iCols.
      GMatrixf​(int iRows, int iCols, float[][] aafMatrix)
      Construct a general matrix of size iRows,iCols.
      GMatrixf​(GMatrixf rkM)
      Construct a general matrix that is the copy of the input matrix.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void Allocate​(boolean bSetToZero)
      Support for allocation and deallocation.
      void Copy​(GMatrixf rkM)
      Set this to the copy of the input matrix.
      private void Deallocate()
      Delete the matrix data.
      void dispose()
      Deallocate the matrix.
      float Get​(int iRow, int iCol)
      Get the value of the matrix at the location iRow, iCol.
      GVectorf GetColumn​(int iCol)
      Get the value of the matrix for the iCol th column.
      int GetColumns()
      Get the number of columns in the matrix.
      float[] GetData()
      Get the matrix values in float[] format.
      void GetData​(float[][] aafMatrix)  
      int GetQuantity()
      Get the size of the matrix rows*columns.
      GVectorf GetRow​(int iRow)
      Get the value of the matrix for the iRow th row.
      int GetRows()
      Get the number of rows in the matrix.
      boolean Inverse()  
      GMatrixf Mult​(GMatrixf rkM)  
      void Set​(int iRow, int iCol, float fValue)
      Set the value of the matrix at the location iRow, iCol.
      void SetColumn​(int iCol, GVectorf rkV)
      Set the value of the matrix for the iCol th column.
      void SetMatrix​(int iRows, int iCols, double[][] aafMatrix)
      Construct a general matrix of size iRows,iCols.
      void SetMatrix​(int iRows, int iCols, float[] afEntry)  
      void SetMatrix​(int iRows, int iCols, float[][] aafMatrix)
      Construct a general matrix of size iRows,iCols.
      void SetRow​(int iRow, GVectorf rkV)
      Set the value of the matrix for the iRow th row.
      void SetSize​(int iRows, int iCols)
      Set the matrix size.
      void SwapRows​(int iRow0, int iRow1)
      Swap the iRow0 and iRow1 in the matrix.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • m_iRows

        private int m_iRows
        rows, columns, and size:
      • m_iCols

        private int m_iCols
        rows, columns, and size:
      • m_iQuantity

        private int m_iQuantity
        rows, columns, and size:
      • m_afData

        private float[] m_afData
        the matrix is stored in row-major form as a 1-dimensional array
    • Constructor Detail

      • GMatrixf

        public GMatrixf()
        Construct a general matrix of size 0,0.
      • GMatrixf

        public GMatrixf​(GMatrixf rkM)
        Construct a general matrix that is the copy of the input matrix.
        Parameters:
        rkM - input matrix.
      • GMatrixf

        public GMatrixf​(int iRows,
                        int iCols)
        Construct a general matrix of size iRows,iCols.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
      • GMatrixf

        public GMatrixf​(int iRows,
                        int iCols,
                        float[] afEntry)
        Construct a general matrix of size iRows,iCols. Copy the afEntry array into the new matrix.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
        afEntry - matrix values.
      • GMatrixf

        public GMatrixf​(int iRows,
                        int iCols,
                        float[][] aafMatrix)
        Construct a general matrix of size iRows,iCols. Copy the afEntry array into the new matrix.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
        aafMatrix - matrix values.
      • GMatrixf

        public GMatrixf​(int iRows,
                        int iCols,
                        double[][] aafMatrix)
        Construct a general matrix of size iRows,iCols. Copy the afEntry array into the new matrix.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
        aafMatrix - matrix values.
    • Method Detail

      • Copy

        public void Copy​(GMatrixf rkM)
        Set this to the copy of the input matrix.
        Parameters:
        rkM - input matrix.
      • dispose

        public void dispose()
        Deallocate the matrix.
      • Get

        public float Get​(int iRow,
                         int iCol)
        Get the value of the matrix at the location iRow, iCol.
        Parameters:
        iRow - row position.
        iCol - column position.
        Returns:
        the matrix value at the location iRow, iCol.
      • GetColumn

        public GVectorf GetColumn​(int iCol)
        Get the value of the matrix for the iCol th column.
        Parameters:
        iCol - column to get.
        Returns:
        a general vector containing the column values.
      • GetColumns

        public int GetColumns()
        Get the number of columns in the matrix.
        Returns:
        the number of rows in the matrix.
      • GetData

        public float[] GetData()
        Get the matrix values in float[] format.
        Returns:
        the matrix values.
      • GetData

        public void GetData​(float[][] aafMatrix)
      • GetQuantity

        public int GetQuantity()
        Get the size of the matrix rows*columns.
        Returns:
        the size of the matrix rows*columns.
      • GetRow

        public GVectorf GetRow​(int iRow)
        Get the value of the matrix for the iRow th row.
        Parameters:
        iRow - row to get.
        Returns:
        a general vector containing the row values.
      • GetRows

        public int GetRows()
        Get the number of rows in the matrix.
        Returns:
        the number of rows in the matrix.
      • Inverse

        public boolean Inverse()
      • Set

        public void Set​(int iRow,
                        int iCol,
                        float fValue)
        Set the value of the matrix at the location iRow, iCol.
        Parameters:
        iRow - row position.
        iCol - column position.
        fValue - new value.
      • SetColumn

        public void SetColumn​(int iCol,
                              GVectorf rkV)
        Set the value of the matrix for the iCol th column.
        Parameters:
        iCol - column to set.
        rkV - general vector containing the new values.
      • SetMatrix

        public void SetMatrix​(int iRows,
                              int iCols,
                              float[] afEntry)
      • SetMatrix

        public void SetMatrix​(int iRows,
                              int iCols,
                              float[][] aafMatrix)
        Construct a general matrix of size iRows,iCols. Copy the afEntry array into the new matrix.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
        aafMatrix - matrix values.
      • SetMatrix

        public void SetMatrix​(int iRows,
                              int iCols,
                              double[][] aafMatrix)
        Construct a general matrix of size iRows,iCols. Copy the afEntry array into the new matrix.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
        aafMatrix - matrix values.
      • SetRow

        public void SetRow​(int iRow,
                           GVectorf rkV)
        Set the value of the matrix for the iRow th row.
        Parameters:
        iRow - row to set.
        rkV - general vector containing the new values.
      • SetSize

        public void SetSize​(int iRows,
                            int iCols)
        Set the matrix size.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
      • SwapRows

        public void SwapRows​(int iRow0,
                             int iRow1)
        Swap the iRow0 and iRow1 in the matrix.
        Parameters:
        iRow0 - first row to swap.
        iRow1 - second row to swap.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • Allocate

        private void Allocate​(boolean bSetToZero)
        Support for allocation and deallocation. The allocation call requires m_iRows, m_iCols, and m_iQuantity to have already been correctly initialized.
        Parameters:
        bSetToZero - when true set the matrix to all 0-values.
      • Deallocate

        private void Deallocate()
        Delete the matrix data.