MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / findPureRotation_

Method findPureRotation_

source/MRMesh/MRPointToPointAligningTransform.cpp:55–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55auto PointToPointAligningTransform::findPureRotation_() const -> BestRotation
56{
57 assert( totalWeight() > 0 );
58
59 // for more detail of this algorithm see paragraph "3.3 A solution involving unit quaternions" in
60 // http://graphics.stanford.edu/~smr/ICP/comparison/eggert_comparison_mva97.pdf
61 const Matrix3d s = sum12_ - outer( sum1_, centroid2() );
62 const SymMatrix4d p = calculateMatrixP( s );
63
64 const Eigen::SelfAdjointEigenSolver<Eigen::Matrix4d> solver( toEigen( p ) );
65 Eigen::Vector4d largestEigenVector = solver.eigenvectors().col( 3 );
66 Quaterniond q( largestEigenVector[0], largestEigenVector[1], largestEigenVector[2], largestEigenVector[3] );
67 return { Matrix3d{ q }, solver.eigenvalues()( 3 ) };
68}
69
70AffineXf3d PointToPointAligningTransform::findBestRigidXf() const
71{

Callers

nothing calls this directly

Calls 4

calculateMatrixPFunction · 0.85
toEigenFunction · 0.85
outerFunction · 0.70
colMethod · 0.45

Tested by

no test coverage detected