PointCloudLibrary / pcl

Point Cloud Library (PCL)

Home Page:https://pointclouds.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[feature] pcl::eigen33 maybe unstable when the algebraic multiplicity of the smallest eigenvalue is not 1

QiMingZhenFan opened this issue · comments

Describe the bug

When solving the eigenvector corresponding to the smallest eigenvalue, pcl use cross-product technique in function getLargest3x3Eigenvector. This may be unavailable when the algebraic multiplicity of the smallest eigenvalue is not 1.

Context

Let λ1, λ2, λ3 be the eigenvalues of a 3*3 covariance matrix A. If λ1 < λ2 < λ3, scaledMat(which is (A-λ1×I), calculated here) has rank 2 and two of its three row vectors are linearly independent. Since the eigenvector are orthogonal to all row vectors of scaledMat, we can obtain the correct eigenvector by applying cross-product on row vectors.

However, if the algebraic multiplicity of the smallest eigenvalue is 2, which means λ1 = λ2 < λ3, scaledMat has rank 1 and all its row vectors are linearly dependent. Thus all the cross-products lead to zero vectors, which is not available for subsequent steps, i.e. solvePlaneParameters.

Hi, is this a purely theoretical consideration, or did you encounter this problem in practice? My intuition would be that in practice, with (typically) noisy data, it is very unlikely that the two smallest eigenvalues are the same. Similar might be possible, but then the question would be, how similar do the eigenvalues have to be to cause this problem? And since you mentioned solvePlaneParameters: if the covariance matrix indeed comes from a planar point cloud, then this problem cannot happen anyways.

@mvieth Thanks for the kindly reply!

Oh, for now it is totally a theoretical consideration. I'm just puzzled when I look at the source code.

Yes, it is almost impossible for two smallest eigenvalues to be the same. In addition to the presence of noise in the data, inaccuracy numerical calculations maybe another reason. As for the question,

Similar might be possible, but then the question would be, how similar do the eigenvalues have to be to cause this problem?

It seems that two similar smallest eigenvectors are unable to cause strict linear correlation between row vectors. Therefore, the cross product operation could always output a non-zero vector.

So, maybe there is no need to consider this kind of situation which can hardly happen?

If we agree that this is very unlikely to be a problem in practice, I would say that it is not worth it to spend a lot of time on it. However, if you like, you could add the following check (copied from the other eigen33 function below):

if ( (eigenvalues (1) - eigenvalues (0)) <= Eigen::NumTraits < Scalar > ::epsilon ())

and then a PCL_WARN(...); to tell the user that the smallest eigenvalue is not unique. Then we can also see if any of our tests print this warning.

OK, I'll close this issue.