本文整理汇总了C++中rdgeom::Transform3D::setToIdentity方法的典型用法代码示例。如果您正苦于以下问题:C++ Transform3D::setToIdentity方法的具体用法?C++ Transform3D::setToIdentity怎么用?C++ Transform3D::setToIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdgeom::Transform3D
的用法示例。
在下文中一共展示了Transform3D::setToIdentity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AlignPoints
double AlignPoints(const RDGeom::Point3DConstPtrVect &refPoints,
const RDGeom::Point3DConstPtrVect &probePoints,
RDGeom::Transform3D &trans, const DoubleVector *weights,
bool reflect, unsigned int maxIterations) {
unsigned int npt = refPoints.size();
PRECONDITION(npt == probePoints.size(), "Mismatch in number of points");
trans.setToIdentity();
const DoubleVector *wts;
double wtsSum;
bool ownWts;
if (weights) {
PRECONDITION(npt == weights->size(), "Mismatch in number of points");
wts = weights;
wtsSum = _sumOfWeights(*wts);
ownWts = false;
} else {
wts = new DoubleVector(npt, 1.0);
wtsSum = static_cast<double>(npt);
ownWts = true;
}
RDGeom::Point3D rptSum = _weightedSumOfPoints(refPoints, *wts);
RDGeom::Point3D pptSum = _weightedSumOfPoints(probePoints, *wts);
double rptSumLenSq = _weightedSumOfLenSq(refPoints, *wts);
double pptSumLenSq = _weightedSumOfLenSq(probePoints, *wts);
double covMat[3][3];
// compute the co-variance matrix
_computeCovarianceMat(refPoints, probePoints, *wts, covMat);
if (ownWts) {
delete wts;
wts = 0;
}
if (reflect) {
rptSum *= -1.0;
reflectCovMat(covMat);
}
// convert the covariance matrix to a 4x4 matrix that needs to be diagonalized
double quad[4][4];
_covertCovMatToQuad(covMat, rptSum, pptSum, wtsSum, quad);
// get the eigenVecs and eigenVals for the matrix
double eigenVecs[4][4], eigenVals[4];
jacobi(quad, eigenVals, eigenVecs, maxIterations);
// get the quaternion
double quater[4];
quater[0] = eigenVecs[0][0];
quater[1] = eigenVecs[1][0];
quater[2] = eigenVecs[2][0];
quater[3] = eigenVecs[3][0];
trans.SetRotationFromQuaternion(quater);
if (reflect) {
// put the flip in the rotation matrix
trans.Reflect();
}
// compute the SSR value
double ssr = eigenVals[0] - (pptSum.lengthSq() + rptSum.lengthSq()) / wtsSum +
rptSumLenSq + pptSumLenSq;
if ((ssr < 0.0) && (fabs(ssr) < TOLERANCE)) {
ssr = 0.0;
}
if (reflect) {
rptSum *= -1.0;
}
// set the translation
trans.TransformPoint(pptSum);
RDGeom::Point3D move = rptSum;
move -= pptSum;
move /= wtsSum;
trans.SetTranslation(move);
return ssr;
}