Cellzilla2D Home


Finds the primary axes of an ellipse that best fits a set of points.


Return Value

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

"Angles"→angles (in radians) between each of the two primary axes and x-axis

"Eigenvalues"→{λ1, λ2} eigenvalues of intertia matrix

"Vectors"→{v1, v2} eigenvectors of intertia matrix

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

PrimaryAxesVectors[{{x1,y1},...}] returns a list containing only the vectors; it is equivalent to "Vectors"/.PrimaryAxes[{{x1,y1},...}]



[ 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