Class Matrix4f
- java.lang.Object
-
- WildMagic.LibFoundation.Mathematics.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 Summary
Fields Modifier and Type Field Description static Matrix4f
IDENTITY
Identity matrix:float
M00
Matrix data:float
M01
Matrix data:float
M02
Matrix data:float
M03
Matrix data:float
M10
float
M11
float
M12
float
M13
float
M20
float
M21
float
M22
float
M23
float
M30
float
M31
float
M32
float
M33
private static long
serialVersionUID
static Matrix4f
ZERO
Zero matrix:
-
Constructor Summary
Constructors Constructor Description Matrix4f()
Create the zero matrix.Matrix4f(boolean bZero)
If bZero is true, create the zero matrix.Matrix4f(float[] afEntry, boolean bRowMajor)
Create a matrix from an array of numbers.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.Matrix4f(Matrix4f rkM)
copy constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Matrix4f
adjoint()
Compute the adjoint of this matrix, setting this: this = Adjoint(this).void
Adjoint()
Deprecated.Matrix4f
copy(Matrix4f rkM)
copy, overwrite this.void
Copy(Matrix4f rkM)
Deprecated.float
determinant()
Return the determinant of this matrix.float
Determinant()
Deprecated.boolean
equals(java.lang.Object kObject)
float
get(int iRow, int iCol)
Get member accessfloat
Get(int iRow, int iCol)
Deprecated.void
getColumnMajor(float[] afCMajor)
Get member access.void
GetColumnMajor(float[] afCMajor)
Deprecated.void
getData(float[] afData)
Get member access.void
GetData(float[] afData)
Deprecated.Matrix4f
identity()
make this the identity matrixMatrix4f
inverse()
Invert a 4x4 using cofactors.static Matrix4f
inverse(Matrix4f kM)
Invert a 4x4 using cofactors.void
Inverse()
Deprecated.void
Inverse(Matrix4f kM)
Deprecated.void
MakeIdentity()
Deprecated.Matrix4f
makeObliqueProjection(Vector3f rkNormal, Vector3f rkPoint, Vector3f rkDirection)
void
MakeObliqueProjection(Vector3f rkNormal, Vector3f rkPoint, Vector3f rkDirection)
Deprecated.Matrix4f
makePerspectiveProjection(Vector3f rkNormal, Vector3f rkPoint, Vector3f rkEye)
void
MakePerspectiveProjection(Vector3f rkNormal, Vector3f rkPoint, Vector3f rkEye)
Deprecated.Matrix4f
makeReflection(Vector3f rkNormal, Vector3f rkPoint)
void
MakeReflection(Vector3f rkNormal, Vector3f rkPoint)
Deprecated.Matrix4f
makeZero()
make this the zero matrixvoid
MakeZero()
Deprecated.Matrix4f
mult(Matrix4f kM)
Multiply this matrix to the input matrix: this = this * kMstatic Matrix4f
mult(Matrix4f kM1, Matrix4f kM2)
Multiply the two input matrices, setting this: this = kM1 * kM2Vector4f
mult(Vector4f kIn)
matrix times vector: kOut = this * kInvoid
mult(Vector4f kIn, Vector4f kOut)
matrix times vector: kOut = this * kInvoid
Mult(Matrix4f kM)
Deprecated.void
Mult(Matrix4f kM1, Matrix4f kM2)
Deprecated.void
Mult(Vector4f kIn, Vector4f kOut)
Deprecated.Matrix4f
multLeft(Matrix4f kM)
Multiply the two input matrices, setting this: this = kM1 * thisVector4f
multLeft(Vector4f kIn)
matrix times vector: v^T * thisvoid
multLeft(Vector4f kIn, Vector4f rkOut)
matrix times vector: v^T * thisvoid
MultLeft(Matrix4f kM)
Deprecated.void
MultLeft(Vector4f kIn, Vector4f rkOut)
Deprecated.Vector4f
multRight(Vector4f kIn)
matrix times vector: kOut = this * kInvoid
multRight(Vector4f kIn, Vector4f kOut)
matrix times vector: kOut = this * kInvoid
MultRight(Vector4f kIn, Vector4f kOut)
Deprecated.float
qForm(Vector4f rkU, Vector4f rkV)
Calculate and return u^T*M*vfloat
QForm(Vector4f rkU, Vector4f rkV)
Deprecated.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.Matrix4f
set(int iRow, int iCol, float fValue)
Set member accessvoid
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.void
Set(int iRow, int iCol, float fValue)
Deprecated.Matrix4f
timesTranspose(Matrix4f kM)
Multiply this matrix by transpose of the input matrix, setting this: this = this * M^Tvoid
TimesTranspose(Matrix4f kM)
Deprecated.java.lang.String
toString()
Returns a string representation of the matrix values.Matrix4f
transpose()
Transpose this matrix, setting this, this = this^Tstatic Matrix4f
transpose(Matrix4f kM)
Transpose the input matrix, setting this, this = kM^Tvoid
Transpose()
Deprecated.void
Transpose(Matrix4f kM)
Deprecated.Matrix4f
transposeTimes(Matrix4f kM)
Transpose this matrix and multiply by input, setting this: this = this^T * Mstatic Matrix4f
transposeTimes(Matrix4f kM1, Matrix4f kM2)
Transpose M1 and multiply by M2, setting this: this = M1^T * M2void
TransposeTimes(Matrix4f kM)
Deprecated.void
TransposeTimes(Matrix4f kM1, Matrix4f kM2)
Deprecated.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
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] entryfM01
- matrix[1] entryfM02
- matrix[2] entryfM03
- matrix[3] entryfM10
- matrix[4] entryfM11
- matrix[5] entryfM12
- matrix[6] entryfM13
- matrix[7] entryfM20
- matrix[8] entryfM21
- matrix[9] entryfM22
- matrix[10] entryfM23
- matrix[11] entryfM30
- matrix[12] entryfM31
- matrix[13] entryfM32
- matrix[14] entryfM33
- 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 matrixbRowMajor
- 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
-
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 classjava.lang.Object
-
Get
public final float Get(int iRow, int iCol)
Deprecated.Get member access- Parameters:
iRow
- row to getiCol
- 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 getiCol
- 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 vectorrkPoint
- pointrkDirection
- direction vector
-
makeObliqueProjection
public Matrix4f makeObliqueProjection(Vector3f rkNormal, Vector3f rkPoint, Vector3f rkDirection)
-
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 vectorrkPoint
- pointrkEye
- eye vector
-
makePerspectiveProjection
public Matrix4f makePerspectiveProjection(Vector3f rkNormal, Vector3f rkPoint, Vector3f rkEye)
-
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 vectorrkPoint
- 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 matrixkM2
- 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 matrixkM2
- second input matrix
-
Mult
public void Mult(Vector4f kIn, Vector4f kOut)
Deprecated.matrix times vector: kOut = this * kIn- Parameters:
kIn
- input vectorkOut
- output vector = this * v
-
mult
public void mult(Vector4f kIn, Vector4f kOut)
matrix times vector: kOut = this * kIn- Parameters:
kIn
- input vectorkOut
- output vector = this * v
-
mult
public Vector4f mult(Vector4f kIn)
matrix times vector: kOut = this * kIn- Parameters:
kIn
- input vectorkOut
- 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
- vectorrkOut
- vector = kIn^T * this
-
multLeft
public void multLeft(Vector4f kIn, Vector4f rkOut)
matrix times vector: v^T * this- Parameters:
kIn
- vectorrkOut
- vector = kIn^T * this
-
multLeft
public Vector4f multLeft(Vector4f kIn)
matrix times vector: v^T * this- Parameters:
kIn
- vectorrkOut
- vector = kIn^T * this
-
MultRight
public void MultRight(Vector4f kIn, Vector4f kOut)
Deprecated.matrix times vector: kOut = this * kIn- Parameters:
kIn
- input vectorkOut
- output vector = this * v
-
multRight
public void multRight(Vector4f kIn, Vector4f kOut)
matrix times vector: kOut = this * kIn- Parameters:
kIn
- input vectorkOut
- output vector = this * v
-
multRight
public Vector4f multRight(Vector4f kIn)
matrix times vector: kOut = this * kIn- Parameters:
kIn
- input vectorkOut
- output vector = this * v
-
QForm
public float QForm(Vector4f rkU, Vector4f rkV)
Deprecated.Calculate and return u^T*M*v- Parameters:
rkU
- urkV
- v- Returns:
- u^T*M*v
-
qForm
public float qForm(Vector4f rkU, Vector4f rkV)
Calculate and return u^T*M*v- Parameters:
rkU
- urkV
- 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] entryfM01
- matrix[1] entryfM02
- matrix[2] entryfM03
- matrix[3] entryfM10
- matrix[4] entryfM11
- matrix[5] entryfM12
- matrix[6] entryfM13
- matrix[7] entryfM20
- matrix[8] entryfM21
- matrix[9] entryfM22
- matrix[10] entryfM23
- matrix[11] entryfM30
- matrix[12] entryfM31
- matrix[13] entryfM32
- matrix[14] entryfM33
- 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] entryfM01
- matrix[1] entryfM02
- matrix[2] entryfM03
- matrix[3] entryfM10
- matrix[4] entryfM11
- matrix[5] entryfM12
- matrix[6] entryfM13
- matrix[7] entryfM20
- matrix[8] entryfM21
- matrix[9] entryfM22
- matrix[10] entryfM23
- matrix[11] entryfM30
- matrix[12] entryfM31
- matrix[13] entryfM32
- matrix[14] entryfM33
- matrix[15] entry
-
Set
public final void Set(int iRow, int iCol, float fValue)
Deprecated.Set member access- Parameters:
iRow
- row to setiCol
- column to setfValue
- new value
-
set
public Matrix4f set(int iRow, int iCol, float fValue)
Set member access- Parameters:
iRow
- row to setiCol
- column to setfValue
- 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 classjava.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
- matrixkM2
- matrix
-
-