Class Matrix4f

  • All Implemented Interfaces:
    java.io.Serializable

    public class Matrix4f
    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.
    See Also:
    Serialized Form
    • Field Detail

      • ZERO

        public static final Matrix4f ZERO
        Zero matrix:
      • IDENTITY

        public static final Matrix4f IDENTITY
        Identity matrix:
      • M00

        public float M00
        Matrix data:
      • M01

        public float M01
        Matrix data:
      • M02

        public float M02
        Matrix data:
      • M03

        public float M03
        Matrix data:
      • M10

        public float M10
      • M11

        public float M11
      • M12

        public float M12
      • M13

        public float M13
      • M20

        public float M20
      • M21

        public float M21
      • M22

        public float M22
      • M23

        public float M23
      • M30

        public float M30
      • M31

        public float M31
      • M32

        public float M32
      • M33

        public float M33
    • Constructor Detail

      • Matrix4f

        public Matrix4f()
        Create the zero matrix.
      • Matrix4f

        public Matrix4f​(boolean bZero)
        If bZero is true, create the zero matrix. Otherwise, create the identity matrix.
        Parameters:
        bZero - when true create the zero matrix, othersize create identity.
      • Matrix4f

        public Matrix4f​(float fM00,
                        float fM01,
                        float fM02,
                        float fM03,
                        float fM10,
                        float fM11,
                        float fM12,
                        float fM13,
                        float fM20,
                        float fM21,
                        float fM22,
                        float fM23,
                        float fM30,
                        float fM31,
                        float fM32,
                        float fM33)
        input Mrc is in row r, column c.
        Parameters:
        fM00 - matrix[0] entry
        fM01 - matrix[1] entry
        fM02 - matrix[2] entry
        fM03 - matrix[3] entry
        fM10 - matrix[4] entry
        fM11 - matrix[5] entry
        fM12 - matrix[6] entry
        fM13 - matrix[7] entry
        fM20 - matrix[8] entry
        fM21 - matrix[9] entry
        fM22 - matrix[10] entry
        fM23 - matrix[11] entry
        fM30 - matrix[12] entry
        fM31 - matrix[13] entry
        fM32 - matrix[14] entry
        fM33 - matrix[15] entry
      • Matrix4f

        public Matrix4f​(float[] afEntry,
                        boolean bRowMajor)
        Create a matrix from an array of numbers. The input array is interpreted based on the Boolean input as true: entry[0..15]={m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22, m23,m30,m31,m32,m33} [row major] false: entry[0..15]={m00,m10,m20,m30,m01,m11,m21,m31,m02,m12,m22, m32,m03,m13,m23,m33} [col major]
        Parameters:
        afEntry - array of values to put in matrix
        bRowMajor - when true copy in row major order.
      • Matrix4f

        public Matrix4f​(Matrix4f rkM)
        copy constructor
        Parameters:
        rkM - matrix to copy
    • Method Detail

      • Adjoint

        public void Adjoint()
        Deprecated.
        Compute the adjoint of this matrix, setting this: this = Adjoint(this).
      • adjoint

        public Matrix4f adjoint()
        Compute the adjoint of this matrix, setting this: this = Adjoint(this).
      • Copy

        public void Copy​(Matrix4f rkM)
        Deprecated.
        copy, overwrite this.
        Parameters:
        rkM - matrix to copy
      • copy

        public Matrix4f copy​(Matrix4f rkM)
        copy, overwrite this.
        Parameters:
        rkM - matrix to copy
      • Determinant

        public float Determinant()
        Deprecated.
        Return the determinant of this matrix.
        Returns:
        the determinant of this matrix.
      • determinant

        public float determinant()
        Return the determinant of this matrix.
        Returns:
        the determinant of this matrix.
      • equals

        public boolean equals​(java.lang.Object kObject)
        Overrides:
        equals in class java.lang.Object
      • Get

        public final float Get​(int iRow,
                               int iCol)
        Deprecated.
        Get member access
        Parameters:
        iRow - row to get
        iCol - column to get
        Returns:
        value at m_afEntry[iRow*4 + iCol];
      • get

        public final float get​(int iRow,
                               int iCol)
        Get member access
        Parameters:
        iRow - row to get
        iCol - column to get
        Returns:
        value at m_afEntry[iRow*4 + iCol];
      • GetColumnMajor

        public void GetColumnMajor​(float[] afCMajor)
        Deprecated.
        Get member access. Copies matrix into input array in Column-Major order.
        Parameters:
        afCMajor - copy matrix into array.
      • getColumnMajor

        public void getColumnMajor​(float[] afCMajor)
        Get member access. Copies matrix into input array in Column-Major order.
        Parameters:
        afCMajor - copy matrix into array.
      • GetData

        public void GetData​(float[] afData)
        Deprecated.
        Get member access. Copies matrix into input array.
        Parameters:
        afData - copy matrix into array.
      • getData

        public void getData​(float[] afData)
        Get member access. Copies matrix into input array.
        Parameters:
        afData - copy matrix into array.
      • Inverse

        public void Inverse()
        Deprecated.
        Invert a 4x4 using cofactors. This is faster than using a generic Gaussian elimination because of the loop overhead of such a method. this = this -1
      • inverse

        public Matrix4f inverse()
        Invert a 4x4 using cofactors. This is faster than using a generic Gaussian elimination because of the loop overhead of such a method. this = this -1
      • Inverse

        public void Inverse​(Matrix4f kM)
        Deprecated.
        Invert a 4x4 using cofactors. This is faster than using a generic Gaussian elimination because of the loop overhead of such a method. this = kM -1
      • inverse

        public static Matrix4f inverse​(Matrix4f kM)
        Invert a 4x4 using cofactors. This is faster than using a generic Gaussian elimination because of the loop overhead of such a method. this = kM -1
      • MakeIdentity

        public void MakeIdentity()
        Deprecated.
        make this the identity matrix
      • identity

        public Matrix4f identity()
        make this the identity matrix
      • MakeObliqueProjection

        public void MakeObliqueProjection​(Vector3f rkNormal,
                                          Vector3f rkPoint,
                                          Vector3f rkDirection)
        Deprecated.
        projection matrices onto a specified plane The projection plane is Dot(N,X-P) = 0 where N is a 3-by-1 unit-length normal vector and P is a 3-by-1 point on the plane. The projection is oblique to the plane, in the direction of the 3-by-1 vector D. Necessarily Dot(N,D) is not zero for this projection to make sense. Given a 3-by-1 point U, compute the intersection of the line U+t*D with the plane to obtain t = -Dot(N,U-P)/Dot(N,D). Then projection(U) = P + [I - D*N^T/Dot(N,D)]*(U-P) A 4-by-4 homogeneous transformation representing the projection is +- -+ M = | D*N^T - Dot(N,D)*I -Dot(N,P)D | | 0^T -Dot(N,D) | +- -+ where M applies to [U^T 1]^T by M*[U^T 1]^T. The matrix is chosen so that M[3][3] > 0 whenever Dot(N,D)
        Parameters:
        rkNormal - normal vector
        rkPoint - point
        rkDirection - direction vector
        • MakePerspectiveProjection

          public void MakePerspectiveProjection​(Vector3f rkNormal,
                                                Vector3f rkPoint,
                                                Vector3f rkEye)
          Deprecated.
          +- -+ M = | Dot(N,E-P)*I - E*N^T -(Dot(N,E-P)*I - E*N^T)*E | | -N^t Dot(N,E) | +- -+ where E is the eye point, P is a point on the plane, and N is a unit-length plane normal.
          Parameters:
          rkNormal - normal vector
          rkPoint - point
          rkEye - eye vector
        • MakeReflection

          public void MakeReflection​(Vector3f rkNormal,
                                     Vector3f rkPoint)
          Deprecated.
          reflection matrix through a specified plane +- -+ M = | I-2*N*N^T 2*Dot(N,P)*N | | 0^T 1 | +- -+ where P is a point on the plane and N is a unit-length plane normal.
          Parameters:
          rkNormal - normal vector
          rkPoint - point
        • MakeZero

          public void MakeZero()
          Deprecated.
          make this the zero matrix
        • makeZero

          public Matrix4f makeZero()
          make this the zero matrix
        • Mult

          public void Mult​(Matrix4f kM)
          Deprecated.
          Multiply this matrix to the input matrix: this = this * kM
          Parameters:
          kM - input matrix
        • mult

          public Matrix4f mult​(Matrix4f kM)
          Multiply this matrix to the input matrix: this = this * kM
          Parameters:
          kM - input matrix
        • Mult

          public void Mult​(Matrix4f kM1,
                           Matrix4f kM2)
          Deprecated.
          Multiply the two input matrices, setting this: this = kM1 * kM2
          Parameters:
          kM1 - first input matrix
          kM2 - second input matrix
        • mult

          public static Matrix4f mult​(Matrix4f kM1,
                                      Matrix4f kM2)
          Multiply the two input matrices, setting this: this = kM1 * kM2
          Parameters:
          kM1 - first input matrix
          kM2 - second input matrix
        • Mult

          public void Mult​(Vector4f kIn,
                           Vector4f kOut)
          Deprecated.
          matrix times vector: kOut = this * kIn
          Parameters:
          kIn - input vector
          kOut - output vector = this * v
        • mult

          public void mult​(Vector4f kIn,
                           Vector4f kOut)
          matrix times vector: kOut = this * kIn
          Parameters:
          kIn - input vector
          kOut - output vector = this * v
        • mult

          public Vector4f mult​(Vector4f kIn)
          matrix times vector: kOut = this * kIn
          Parameters:
          kIn - input vector
          kOut - output vector = this * v
        • MultLeft

          public void MultLeft​(Matrix4f kM)
          Deprecated.
          Multiply the two input matrices, setting this: this = kM1 * this
          Parameters:
          kM - first input matrix
        • multLeft

          public Matrix4f multLeft​(Matrix4f kM)
          Multiply the two input matrices, setting this: this = kM1 * this
          Parameters:
          kM - first input matrix
        • MultLeft

          public void MultLeft​(Vector4f kIn,
                               Vector4f rkOut)
          Deprecated.
          matrix times vector: v^T * this
          Parameters:
          kIn - vector
          rkOut - vector = kIn^T * this
        • multLeft

          public void multLeft​(Vector4f kIn,
                               Vector4f rkOut)
          matrix times vector: v^T * this
          Parameters:
          kIn - vector
          rkOut - vector = kIn^T * this
        • multLeft

          public Vector4f multLeft​(Vector4f kIn)
          matrix times vector: v^T * this
          Parameters:
          kIn - vector
          rkOut - vector = kIn^T * this
        • MultRight

          public void MultRight​(Vector4f kIn,
                                Vector4f kOut)
          Deprecated.
          matrix times vector: kOut = this * kIn
          Parameters:
          kIn - input vector
          kOut - output vector = this * v
        • multRight

          public void multRight​(Vector4f kIn,
                                Vector4f kOut)
          matrix times vector: kOut = this * kIn
          Parameters:
          kIn - input vector
          kOut - output vector = this * v
        • multRight

          public Vector4f multRight​(Vector4f kIn)
          matrix times vector: kOut = this * kIn
          Parameters:
          kIn - input vector
          kOut - output vector = this * v
        • QForm

          public float QForm​(Vector4f rkU,
                             Vector4f rkV)
          Deprecated.
          Calculate and return u^T*M*v
          Parameters:
          rkU - u
          rkV - v
          Returns:
          u^T*M*v
        • qForm

          public float qForm​(Vector4f rkU,
                             Vector4f rkV)
          Calculate and return u^T*M*v
          Parameters:
          rkU - u
          rkV - v
          Returns:
          u^T*M*v
        • Set

          public final void Set​(float fM00,
                                float fM01,
                                float fM02,
                                float fM03,
                                float fM10,
                                float fM11,
                                float fM12,
                                float fM13,
                                float fM20,
                                float fM21,
                                float fM22,
                                float fM23,
                                float fM30,
                                float fM31,
                                float fM32,
                                float fM33)
          Deprecated.
          input Mrc is in row r, column c.
          Parameters:
          fM00 - matrix[0] entry
          fM01 - matrix[1] entry
          fM02 - matrix[2] entry
          fM03 - matrix[3] entry
          fM10 - matrix[4] entry
          fM11 - matrix[5] entry
          fM12 - matrix[6] entry
          fM13 - matrix[7] entry
          fM20 - matrix[8] entry
          fM21 - matrix[9] entry
          fM22 - matrix[10] entry
          fM23 - matrix[11] entry
          fM30 - matrix[12] entry
          fM31 - matrix[13] entry
          fM32 - matrix[14] entry
          fM33 - matrix[15] entry
        • set

          public Matrix4f set​(float fM00,
                              float fM01,
                              float fM02,
                              float fM03,
                              float fM10,
                              float fM11,
                              float fM12,
                              float fM13,
                              float fM20,
                              float fM21,
                              float fM22,
                              float fM23,
                              float fM30,
                              float fM31,
                              float fM32,
                              float fM33)
          input Mrc is in row r, column c.
          Parameters:
          fM00 - matrix[0] entry
          fM01 - matrix[1] entry
          fM02 - matrix[2] entry
          fM03 - matrix[3] entry
          fM10 - matrix[4] entry
          fM11 - matrix[5] entry
          fM12 - matrix[6] entry
          fM13 - matrix[7] entry
          fM20 - matrix[8] entry
          fM21 - matrix[9] entry
          fM22 - matrix[10] entry
          fM23 - matrix[11] entry
          fM30 - matrix[12] entry
          fM31 - matrix[13] entry
          fM32 - matrix[14] entry
          fM33 - matrix[15] entry
        • Set

          public final void Set​(int iRow,
                                int iCol,
                                float fValue)
          Deprecated.
          Set member access
          Parameters:
          iRow - row to set
          iCol - column to set
          fValue - new value
        • set

          public Matrix4f set​(int iRow,
                              int iCol,
                              float fValue)
          Set member access
          Parameters:
          iRow - row to set
          iCol - column to set
          fValue - new value
        • TimesTranspose

          public void TimesTranspose​(Matrix4f kM)
          Deprecated.
          Multiply this matrix by transpose of the input matrix, setting this: this = this * M^T
          Parameters:
          kM - matrix
        • timesTranspose

          public Matrix4f timesTranspose​(Matrix4f kM)
          Multiply this matrix by transpose of the input matrix, setting this: this = this * M^T
          Parameters:
          kM - matrix
        • toString

          public java.lang.String toString()
          Returns a string representation of the matrix values.
          Overrides:
          toString in class java.lang.Object
          Returns:
          string representation of the matrix values.
        • Transpose

          public void Transpose()
          Deprecated.
          Transpose this matrix, setting this, this = this^T
        • transpose

          public Matrix4f transpose()
          Transpose this matrix, setting this, this = this^T
        • Transpose

          public void Transpose​(Matrix4f kM)
          Deprecated.
          Transpose the input matrix, setting this, this = kM^T
        • transpose

          public static Matrix4f transpose​(Matrix4f kM)
          Transpose the input matrix, setting this, this = kM^T
        • TransposeTimes

          public void TransposeTimes​(Matrix4f kM)
          Deprecated.
          Transpose this matrix and multiply by input, setting this: this = this^T * M
          Parameters:
          kM - matrix
        • transposeTimes

          public Matrix4f transposeTimes​(Matrix4f kM)
          Transpose this matrix and multiply by input, setting this: this = this^T * M
          Parameters:
          kM - matrix
        • TransposeTimes

          public void TransposeTimes​(Matrix4f kM1,
                                     Matrix4f kM2)
          Deprecated.
          Transpose M1 and multiply by M2, setting this: this = M1^T * M2
          Parameters:
          kM1 - matrix
          kM2 - matrix
        • transposeTimes

          public static Matrix4f transposeTimes​(Matrix4f kM1,
                                                Matrix4f kM2)
          Transpose M1 and multiply by M2, setting this: this = M1^T * M2
          Parameters:
          kM1 - matrix
          kM2 - matrix