# Comparison tow shapes

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

## 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 on other sites
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 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 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.

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633363
• Total Posts
3011514
• ### Who's Online (See full list)

There are no registered users currently online

×