I need to implement the algorithm described below. Everything is fine until the eigenvalues computation. I'm completely new to them and I found a lot of very complicated paper on the net. Is it possible that this 'best-fitting plane' case requires such a complex approach? Where can I find straightforward implementation of a suitable eigenvalue solver for this?

I am also interested in different approaches to the 'best-fitting plane' problem.


xm = mean(x); ym = mean(y); zm = mean(z);

u = x - xm; v = y - ym; w = z - zm;

M = [sum(u.^2),sum(u.*v),sum(u.*w); ...
     sum(v.*u),sum(v.^2),sum(v.*w); ...

[V,D] = eig(M);

Now choose the smallest eigenvalue in D. The corresponding eigenvector in V gives the coefficients, v1, v2, v3, in the best-fitting plane:

v1*(X-xm) + v2*(Y-ym) + v3*(Z-zm) = 0

By the way, if that smallest eigenvalue should turn out to be zero, that is your indication that the four points are coplanar and your plane is an exact fit.

  • $\begingroup$ Yes, this is the correct approach for the best-fitting plane. To get useful responses where to find a suitable eigenvalue solver, you should probably tell us more about your computing environment and requirements. $\endgroup$ – joriki Nov 14 '11 at 9:43
  • 1
    $\begingroup$ Bleh, I don't recommend this method, though. Better to use SVD instead of the eigendecomposition for these matters... $\endgroup$ – J. M. is a poor mathematician Nov 14 '11 at 9:52
  • $\begingroup$ @J.M.: I don't understand -- since $M$ is symmetric, isn't that the same thing? $\endgroup$ – joriki Nov 14 '11 at 9:58
  • $\begingroup$ @joriki: theoretically, yes. Computationally, a bad idea, since the cross-product matrix's condition number is the square of the condition number of the design matrix. See this previous answer of mine, where I show a simple example due to Läuchli. $\endgroup$ – J. M. is a poor mathematician Nov 14 '11 at 10:56
  • $\begingroup$ @J.M.: Ah, I see, sorry -- I thought you were suggesting to apply SVD instead of eigendecomposition to the covariance matrix :-) $\endgroup$ – joriki Nov 14 '11 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.