
Geometry : 
Subject: Re: [geometry] fit an ellipse to a polygon
From: Barend Gehrels (barend_at_[hidden])
Date: 20130814 11:04:58
Hi Tanaka,
On 1482013 11:55, Tanaka Simon wrote:
> Hello,
>
> I have a model::polygon, and i want to fit an ellipse to it (see link
> below). do you have suggestions of how to use (builtin)
> boost::geometry functionality as much as possible?
>
> do you have alternative suggestions to characterize the polygon, e.g.
> to compute the principal axes of the inertia tensor? the solution is
> allowed to be heuristic.
Interesting problem. You could use distance (pointlinestring) to get
the distance from each point to the ellipseasalinestring. Note that
if you model the ellipse as a polygon, the distance is zero for all
points inside, so I would use a linestring here. This ellipse can easily
be generated from the definition of the ellipse.
To start with you could think of calculating the convex hull of the
points. That gives a reasonable startingshape. Its centroid should be
located in the neighbourhood of the center of the ellipse. And then
indeed you would need the diameter... You could use the point at the
furthest location from the ellipse here as a starting point (then you
also have some idea of the direction of the axis).
Regards, Barend
Geometry list run by mateusz at loskot.net