Sign in to follow this  
mSafdel

Comparison tow shapes

Recommended Posts

What is meant with "size"? A bounding box, the surrounded area, or what? And what kinds of shapes are possible? Polygonal, or also with curved boundaries? Is self intersection possible? Are holes possible?

E.g., if a shape is polygonal and non self intersecting than e.g. triangulate it (ear-clipping, Seidel's algorithm, ...) and sum up the sizes of each triangle to get the area.

Share this post


Link to post
Share on other sites
Let me get this straight:

A user draws two closed curves in the plane. Now, do you want,
(1) to compute the area enclosed by each curve
or
(2) do you want some measure of how "different" the two shapes are (e.g., a circle of radius r/pi[sup]2[/sup] and a square with side length [i]r[/i] both have area=1, but you want to distinguish them)?

If #1, there are two ways to do this depending on how you handle self-intersection. If signed area is ok, just use the [url="http://en.wikipedia.org/wiki/Polygon#Area_and_centroid"]Surveyor's Formula[/url]; otherwise you'll need to triangulate as haegarr suggested.

If #2, there are various metrics, and we should talk about what your requirements are. One standard measure of the distance between two sets is the [url="http://en.wikipedia.org/wiki/Hausdorff_distance"]Hausdorff distance[/url], but there are other reasonable things you could also do, like comparing [url="http://en.wikipedia.org/wiki/Moment_%28mathematics%29"]moments[/url].

Share this post


Link to post
Share on other sites
thanks my friends. my goal is "compute the area enclosed by each curve".
I read your answers, in my opinion i can use ear-clipping and Seidel's algorithm for my game. thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this