Determinants
This commit is contained in:
parent
fb16e0960b
commit
2cadec3bed
|
@ -288,10 +288,10 @@ public class Matrix3f {
|
|||
* @return the transposed matrix
|
||||
*/
|
||||
public Matrix3f transpose(Matrix3f dest) {
|
||||
|
||||
|
||||
if (dest == null)
|
||||
dest = new Matrix3f();
|
||||
|
||||
|
||||
if (this != dest) {
|
||||
m00 = dest.m00;
|
||||
m01 = dest.m10;
|
||||
|
@ -304,9 +304,20 @@ public class Matrix3f {
|
|||
m22 = dest.m22;
|
||||
} else
|
||||
transpose();
|
||||
|
||||
|
||||
return this;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the determinant of the matrix
|
||||
*/
|
||||
public float determinant() {
|
||||
float f =
|
||||
m00 * (m11 * m22 - m12 * m21)
|
||||
+ m01 * (m12 * m20 - m10 * m22)
|
||||
+ m02 * (m10 * m21 - m11 * m20);
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -395,9 +395,37 @@ public class Matrix4f {
|
|||
m33 = dest.m33;
|
||||
} else
|
||||
transpose();
|
||||
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the determinant of the matrix
|
||||
*/
|
||||
public float determinant() {
|
||||
float f =
|
||||
m00
|
||||
* ((m11 * m22 * m33 + m12 * m23 * m31 + m13 * m21 * m32)
|
||||
- m13 * m22 * m31
|
||||
- m11 * m23 * m32
|
||||
- m12 * m21 * m33);
|
||||
f -= m01
|
||||
* ((m10 * m22 * m33 + m12 * m23 * m30 + m13 * m20 * m32)
|
||||
- m13 * m22 * m30
|
||||
- m10 * m23 * m32
|
||||
- m12 * m20 * m33);
|
||||
f += m02
|
||||
* ((m10 * m21 * m33 + m11 * m23 * m30 + m13 * m20 * m31)
|
||||
- m13 * m21 * m30
|
||||
- m10 * m23 * m31
|
||||
- m11 * m20 * m33);
|
||||
f -= m03
|
||||
* ((m10 * m21 * m32 + m11 * m22 * m30 + m12 * m20 * m31)
|
||||
- m12 * m21 * m30
|
||||
- m10 * m22 * m31
|
||||
- m11 * m20 * m32);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue