FitEllipse Cellzilla2D Home


Fits an ellipse to a set of points.


Return Value

FitEllipse[{{x1,y}, {x2, y2}, ...}] returns information about a "best fit" ellipse as an option list:

"Angle"→angle (in radians) between semimajor-axis and x-axis

"Axes"→{vx,vy} vector in direction of semi-major axis and length equal to semi-major axis;

"Graphics"→graphics object with simple plot of object and directions of major and minor axes.



[ Download Example as Zipped Mathematica Notebook ]

Implementation Notes

The primary axes are found by first translating the ellipse into center-of-mass coordinates V={{x1', y1'), {x2',y2'},...} where each {xi', yi'}={xi,yi}-{xc,yc}, and {xc,yc} is the center of mass. Then the eigenvalues and eigenvectors of the matrix

are calculated. The ratio of of semi-major to semi-minor axis is taken as the square root of the ratio of the larger eigenvalue to the smaller eigenvalue. The actual values of a and be determined so that πab equals the area of the original polygon. The directions of the semi-major and semi-minor axes are given by the normalized eigenvectors.

See Also