POLYGONINERTIAELLIPSE Compute ellipse with same inertia moments as polygon.
ELLI = polygonInertiaEllipse(POLY)
Example
% convert an ellipse to polygon, and check that inertia ellipse is
% close to original ellipse
elli = [50 50 50 30 20];
poly = ellipseToPolygon(elli, 1000);
polygonInertiaEllipse(poly)
ans =
50.0000 50.0000 49.9998 29.9999 20.0000
% compute inertia ellipse of more complex figure
img = imread('circles.png');
img = imfill(img, 'holes');
figure; imshow(img); hold on;
B = bwboundaries(img);
poly = B{1}(:,[2 1]);
drawPolygon(poly, 'r');
elli = polygonInertiaEllipse(poly);
drawEllipse(elli, 'color', 'g', 'linewidth', 2);
See also
polygons2d, polygonSecondAreaMoments, polygonCentroid, inertiaEllipse
ellipseToPolygon
Package: matgeom