本文整理汇总了C++中base::Matrix4D::determinant方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4D::determinant方法的具体用法?C++ Matrix4D::determinant怎么用?C++ Matrix4D::determinant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base::Matrix4D
的用法示例。
在下文中一共展示了Matrix4D::determinant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sqrt
// Analyse the a transformation Matrix and describe the transformation
std::string Matrix4D::analyse(void) const
{
const double eps=1.0e-06;
bool hastranslation = (dMtrx4D[0][3] != 0.0 ||
dMtrx4D[1][3] != 0.0 || dMtrx4D[2][3] != 0.0);
const Base::Matrix4D unityMatrix = Base::Matrix4D();
std::string text;
if (*this == unityMatrix)
{
text = "Unity Matrix";
}
else
{
if (dMtrx4D[3][0] != 0.0 || dMtrx4D[3][1] != 0.0 ||
dMtrx4D[3][2] != 0.0 || dMtrx4D[3][3] != 1.0)
{
text = "Projection";
}
else //translation and affine
{
if (dMtrx4D[0][1] == 0.0 && dMtrx4D[0][2] == 0.0 &&
dMtrx4D[1][0] == 0.0 && dMtrx4D[1][2] == 0.0 &&
dMtrx4D[2][0] == 0.0 && dMtrx4D[2][1] == 0.0) //scaling
{
std::ostringstream stringStream;
stringStream << "Scale [" << dMtrx4D[0][0] << ", " <<
dMtrx4D[1][1] << ", " << dMtrx4D[2][2] << "]";
text = stringStream.str();
}
else
{
Base::Matrix4D sub;
sub[0][0] = dMtrx4D[0][0]; sub[0][1] = dMtrx4D[0][1];
sub[0][2] = dMtrx4D[0][2]; sub[1][0] = dMtrx4D[1][0];
sub[1][1] = dMtrx4D[1][1]; sub[1][2] = dMtrx4D[1][2];
sub[2][0] = dMtrx4D[2][0]; sub[2][1] = dMtrx4D[2][1];
sub[2][2] = dMtrx4D[2][2];
Base::Matrix4D trp = sub;
trp.transpose();
trp = trp * sub;
bool ortho = true;
for (int i=0; i<4 && ortho; i++) {
for (int j=0; j<4 && ortho; j++) {
if (i != j) {
if (fabs(trp[i][j]) > eps) {
ortho = false;
break;
}
}
}
}
double determinant = sub.determinant();
if (ortho)
{
if (fabs(determinant-1.0)<eps ) //rotation
{
text = "Rotation Matrix";
}
else
{
if (fabs(determinant+1.0)<eps ) //rotation
{
text = "Rotinversion Matrix";
}
else //scaling with rotation
{
std::ostringstream stringStream;
stringStream << "Scale and Rotate ";
if (determinant<0.0 )
stringStream << "and Invert ";
stringStream << "[ " <<
sqrt(trp[0][0]) << ", " << sqrt(trp[1][1]) << ", " <<
sqrt(trp[2][2]) << "]";
text = stringStream.str();
}
}
}
else
{
std::ostringstream stringStream;
stringStream << "Affine with det= " <<
determinant;
text = stringStream.str();
}
}
}
if (hastranslation)
text += " with Translation";
}
return text;
}