The Matlab Mapping Toolbox allows one to perform several useful arithmetic operations with polygons, including finding the intersection (POLYBOOL) and areas (POLYAREA) of polygons.
A warning message you may see when working with POLYBOOL is
Warning: (X1,Y1) contains no external contours. Function POLYBOOL assumes that that external contours have
clockwise-ordered vertices, and all contours in (X1,Y1) have counterclockwise-ordered vertices. Use POLY2CW
to reverse the vertex order if necessary.
Here is what Matlab means by “external contours” and “internal contours”.
External contour: the vertices describing the outer edge of a polygon–the outside of a donut, for example. These vertices must be given in CLOCKWISE order.
Internal contour: the vertices describing an area in which the convex hull is hollow (the donut hole). These vertices must be given in COUNTERclockwise order.