Jump to content
  • Advertisement
Sign in to follow this  
mSafdel

Comparison tow shapes

This topic is 2603 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have 2 shapes (2D) that drawing by user. i want to comparison size of shapes. how can i that? shapes may be simple for example a triangle or maybe complex.

Share this post


Link to post
Share on other sites
Advertisement
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 r 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 Surveyor's Formula; 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 Hausdorff distance, but there are other reasonable things you could also do, like comparing moments.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!