本文整理汇总了C++中Matrix3x3::CalculateDeterminant方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3x3::CalculateDeterminant方法的具体用法?C++ Matrix3x3::CalculateDeterminant怎么用?C++ Matrix3x3::CalculateDeterminant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix3x3
的用法示例。
在下文中一共展示了Matrix3x3::CalculateDeterminant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cofactors
a2de::Matrix3x3 Matrix3x3::Inverse(const Matrix3x3& mat) {
//Minors, Cofactors, Adjugates method.
//See http://www.mathsisfun.com/algebra/matrix-inverse-minors-cofactors-adjugate.html
//[00 01 02] [0 1 2]
//[10 11 12] [3 4 5]
//[20 21 22] [6 7 8]
//Calculate minors
double m00 = Matrix2x2::CalculateDeterminant(Matrix2x2(mat._indicies[4], mat._indicies[5], mat._indicies[7], mat._indicies[8]));
double m01 = Matrix2x2::CalculateDeterminant(Matrix2x2(mat._indicies[3], mat._indicies[5], mat._indicies[6], mat._indicies[7]));
double m02 = Matrix2x2::CalculateDeterminant(Matrix2x2(mat._indicies[3], mat._indicies[4], mat._indicies[6], mat._indicies[7]));
double m10 = Matrix2x2::CalculateDeterminant(Matrix2x2(mat._indicies[1], mat._indicies[2], mat._indicies[7], mat._indicies[8]));
double m11 = Matrix2x2::CalculateDeterminant(Matrix2x2(mat._indicies[0], mat._indicies[2], mat._indicies[6], mat._indicies[7]));
double m12 = Matrix2x2::CalculateDeterminant(Matrix2x2(mat._indicies[0], mat._indicies[1], mat._indicies[6], mat._indicies[7]));
double m20 = Matrix2x2::CalculateDeterminant(Matrix2x2(mat._indicies[1], mat._indicies[2], mat._indicies[4], mat._indicies[5]));
double m21 = Matrix2x2::CalculateDeterminant(Matrix2x2(mat._indicies[0], mat._indicies[2], mat._indicies[3], mat._indicies[5]));
double m22 = Matrix2x2::CalculateDeterminant(Matrix2x2(mat._indicies[0], mat._indicies[1], mat._indicies[3], mat._indicies[4]));
Matrix3x3 cofactors(m00, -m01, m02,
-m10, m11, -m12,
m20, -m21, m22);
Matrix3x3 adjugate(Matrix3x3::Transpose(cofactors));
double det_mat = mat.CalculateDeterminant();
double inv_det = 1.0 / det_mat;
return inv_det * adjugate;
}