[Math] How to calculate the area of bizarre shapes

approximationgeometrynumerical methods

I'm looking for an algorithm to calculate the area of various shapes (created out of basic shapes such as circles, rectangles, etc…). There are various possibilities such as the area of 2 circles, 1 triangular and 1 square (intersections possible). As you can see this gets quite complicated and requires a numeric solution.

Of course, there are various special cases which can be calculated without any problems, but just as there are simple cases, there are also complex structures.

The only thing which comes to my mind is to write an algorithm which fills these geometrical structures with small squares and sums them up, but maybe there are already some smarter solutions.

Maybe I could also put the whole geometrical shape in a rectangle, and approximate the outlines of my shapes, and then calculate the area outside of my shape, and afterwards subtract the calculated area from the area of the rectangle.

I'm quite confident that these methods would work; it's just a matter of efficiency.

Best Answer

If you can convert your "bizarre shape" into a (non-self-intersecting) polygon (possibly replacing circle arcs with polygonal approximations), one thing you can do to approximate the area is to use the formula for the area of a polygon, given the coordinates of the vertices (a.k.a. the "shoelace formula").

Related Question