本文整理汇总了C++中SbMatrix::makeIdentity方法的典型用法代码示例。如果您正苦于以下问题:C++ SbMatrix::makeIdentity方法的具体用法?C++ SbMatrix::makeIdentity怎么用?C++ SbMatrix::makeIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SbMatrix
的用法示例。
在下文中一共展示了SbMatrix::makeIdentity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateContactVisu
void SimDynamicsWindow::updateContactVisu()
{
contactsSep->removeAllChildren();
SoUnits* u = new SoUnits;
u->units = SoUnits::MILLIMETERS;
contactsSep->addChild(u);
if (!UI.checkBoxContacts->isChecked())
{
return;
}
std::vector<SimDynamics::DynamicsEngine::DynamicsContactInfo> c = dynamicsWorld->getEngine()->getContacts();
for (size_t i = 0; i < c.size(); i++)
{
cout << "Contact: " << c[i].objectAName << " + " << c[i].objectBName << endl;
SoSeparator* normal = new SoSeparator;
SoMatrixTransform* m = new SoMatrixTransform;
SbMatrix ma;
ma.makeIdentity();
ma.setTranslate(SbVec3f(c[i].posGlobalB(0), c[i].posGlobalB(1), c[i].posGlobalB(2)));
m->matrix.setValue(ma);
normal->addChild(m);
SoSeparator* n = CoinVisualizationFactory::CreateArrow(c[i].normalGlobalB, 50.0f);
if (n)
{
normal->addChild(n);
}
SoSeparator* normal2 = new SoSeparator;
SoMatrixTransform* m2 = new SoMatrixTransform;
ma.makeIdentity();
ma.setTranslate(SbVec3f(c[i].posGlobalA(0), c[i].posGlobalA(1), c[i].posGlobalA(2)));
m2->matrix.setValue(ma);
normal2->addChild(m2);
SoSeparator* n2 = CoinVisualizationFactory::CreateArrow(-c[i].normalGlobalB, 50.0f);
if (n2)
{
normal2->addChild(n2);
}
contactsSep->addChild(normal);
contactsSep->addChild(normal2);
}
}
示例2: SbMatrix
SbBool
SbMatrix::factor(SbMatrix &r, SbVec3f &s, SbMatrix &u, SbVec3f &t,
SbMatrix &proj) const
{
double det; /* Determinant of matrix A */
double det_sign; /* -1 if det < 0, 1 if det > 0 */
double scratch;
int i, j;
int junk;
SbMatrix a, b, si;
float evalues[3];
SbVec3f evectors[3];
a = *this;
proj.makeIdentity();
scratch = 1.0;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
a.matrix[i][j] *= scratch;
}
t[i] = matrix[3][i] * scratch;
a.matrix[3][i] = a.matrix[i][3] = 0.0;
}
a.matrix[3][3] = 1.0;
/* (3) Compute det A. If negative, set sign = -1, else sign = 1 */
det = a.det3();
det_sign = (det < 0.0 ? -1.0 : 1.0);
if (det_sign * det < 1e-12)
return(FALSE); // singular
/* (4) B = A * A^ (here A^ means A transpose) */
b = a * a.transpose();
b.jacobi3(evalues, evectors, junk);
// find min / max eigenvalues and do ratio test to determine singularity
r = SbMatrix(evectors[0][0], evectors[0][1], evectors[0][2], 0.0,
evectors[1][0], evectors[1][1], evectors[1][2], 0.0,
evectors[2][0], evectors[2][1], evectors[2][2], 0.0,
0.0, 0.0, 0.0, 1.0);
/* Compute s = sqrt(evalues), with sign. Set si = s-inverse */
si.makeIdentity();
for (i = 0; i < 3; i++) {
s[i] = det_sign * sqrt(evalues[i]);
si.matrix[i][i] = 1.0 / s[i];
}
/* (5) Compute U = R^ S! R A. */
u = r * si * r.transpose() * a;
return(TRUE);
}
示例3: appendTransform
void MicrotubuleTransformOperation::appendTransform(HxParameter* p,
const SbMatrix& mat) {
// get existing transform m
SbMatrix m;
double res[16];
if (p->getDimension() == 16) {
p->getReal(res);
float* ptr = &m[0][0];
for (int i = 0; i < 16; ++i) {
ptr[i] = float(res[i]);
}
} else {
m.makeIdentity();
}
// append transform mat and write parameter
m.multRight(mat);
p->set(16, &m[0][0]);
}