Skip to content

Commit

Permalink
Enforce right-hand-rule on PCA Eigenvectors.
Browse files Browse the repository at this point in the history
Since eigenvectors can be interpreted as a vector space basis (i.e. a Rotation matrix) this commits enforce the behavior where the eigenvectors follow the right-hand rule and thus can be used directly as a rotation matrix/space vector basis.

This PR addresses the issue pointed out in PointCloudLibrary#2879
  • Loading branch information
Danfoa committed Mar 26, 2019
1 parent c20130b commit ca30eb3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/include/pcl/common/impl/pca.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ pcl::PCA<PointT>::initCompute ()
eigenvalues_[i] = evd.eigenvalues () [2-i];
eigenvectors_.col (i) = evd.eigenvectors ().col (2-i);
}
// Enforce right hand rule
eigenvectors_.col(2) = eigenvectors_.col(0).cross(eigenvectors_.col(1));
// If not basis only then compute the coefficients
if (!basis_only_)
coefficients_ = eigenvectors_.transpose() * cloud_demean.topRows<3> ();
Expand Down

0 comments on commit ca30eb3

Please sign in to comment.