Last active
November 4, 2021 14:50
-
-
Save michalpelka/e2081d4d50106bcfd9f2e940d4231606 to your computer and use it in GitHub Desktop.
orthogonize.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Eigen::Affine3d m3d_utils::orthogonize(const Eigen::Affine3d& p ) | |
| { | |
| Eigen::Matrix4d ret = p.matrix(); | |
| Eigen::JacobiSVD<Eigen::Matrix3d> svd(ret.block<3,3>(0,0), Eigen::ComputeFullU | Eigen::ComputeFullV); | |
| double d = (svd.matrixU() * svd.matrixV().transpose()).determinant(); | |
| Eigen::Matrix3d diag = Eigen::Matrix3d::Identity() * d; | |
| ret.block<3,3>(0,0) = svd.matrixU() * diag * svd.matrixV().transpose(); | |
| return Eigen::Affine3d (ret); | |
| // Eigen::Affine3d pose_orto(Eigen::Affine3d::Identity()); | |
| // Eigen::Quaterniond q1(p.matrix().block<3,3>(0,0)); q1.normalize(); | |
| // pose_orto.translate(p.matrix().block<3,1>(0,3)); | |
| // pose_orto.rotate(q1); | |
| // return pose_orto; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment