I know these codes exist for spheres and cones but cannot
find one for an ellipsoid...
Regards,
Bram
Bram --
The general form for an ellipsoid is
Ax^2 + By^2 + Cz^2 + Dxy + Eyz + Fxz + Gx + Hy + Iz + J = 0
The equation is linear in A,..,J so if you have enough data
points you can estimate them using simple least squares.
Note that J is really unnecessary for this and will just
scale A,...,I. I am also not sure that this general form
is completely necessary, perhaps some other poster that
knows solid geometry better than I can say so.
I will let you figure out how to use A,...,I to calculate
the center and major/minor axes!
-Justin
Note that the linear least squares mentioned doesn't minimize (sum of
squares of) geometric distance from the points to the surface, it
minimizes the algebraic distance (i.e. how nonzero that equation is).
That will be fine if you have sufficient points which are not too
noisy, and is in all likelihood what you want.
For the homogeneous equation above (in Justin's post), simple (not
equivalent) linear least squares formulations would involve one of the
following constraints:
1) Let J = 1 and use Matlab's backslash to solve it
2) Let norm([A B ... I J]) = 1 and use the svd
Writing a nonlinear least squares routine to minimise geometric
distance will be significantly more complicated. It's complex enough
to do it for an ellipse, e.g. see my fitellipse submission on the file
exchange:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=15125
You might want to read the paper cited in that submission to get an
idea of what's involved :
"Least-Squares Fitting of Circles and Ellipses", W. Gander, G. H.
Golub, R. Strebel, BIT Numerical Mathematics, Springer 1994
Without ever having done it myself, I'm guessing that the mathematical
formulation of the geometric least squares problem for an ellipsoid
would be similar to the ellipse formulation described therein.
hope that helps,
Richard
This paper discusses the 3-D case:
Feddema, J. T., and Little, C. Q., 1997, ‘‘Rapid World
Modeling: Fitting Range Data to Geometric Primitives,’’
Proceedings of the IEEE International Conference on Robotics
and Automation, 4, pp. 2807 – 2812.