Assuming a series of points in 2d space that do not self-intersect, what is an efficient method of determining the area of the resulting polygon?
As a side note, this is not homework and I am not looking for code. I am looking for a description I can use to implement my own method. I have my ideas about pulling a sequence of triangles from the list of points, but I know there are a bunch of edge cases regarding convex and concave polygons that I probably won't catch.
My inclination would be to simply start slicing off triangles. I don't see how anything else could avoid being awfully hairy.
Take three sequential points that comprise the polygon. Ensure the angle is less than 180. You now have a new triangle which should be no problem to calculate, delete the middle point from the polygon's list of points. Repeat until you have only three points left.
Implementation of Shoelace formula could be done in Numpy. Assuming these vertices:
We can define the following function to find area:
And getting results:
Avoiding loop makes this function ~50X faster than
PolygonArea
:Note: I had written this answer for another question, I just mention this here to have a complete list of solutions.
A set of points without any other constraints don't necessarily uniquely define a polygon.
So, first you have to decide what polygon to build from these points - perhaps the convex hull? http://en.wikipedia.org/wiki/Convex_hull
Then triangulate and calculate area. http://www.mathopenref.com/polygonirregulararea.html
Or do a contour integral. Stokes' Theorem allows you to express an area integral as a contour integral. A little Gauss quadrature and Bob's your uncle.