# Finding Vertices of a Polygonal Region

I am trying to get a vertex list for a polygonal region made from the RegionDifference of two Polygons, and I am unsure of how to do so. For example:

region1 = Polygon[{{310, 577.315}, {310, 708}, {228.998, 708},
{160, 588.451}, {160, 404}, {210.065, 404}}];
region2 = Polygon[{{101.341, 364.}, {330., 187.811}, {558.659, 364.}, {330., 760.283}}];
regionDiff = RegionDifference[region1, region2];


So, I'd like to find the vertices of regionDiff.

Other options for getting a vertex list for the difference of two polygons are also welcome.

• What version of Mathematica are you using? For version 11.2, regionDiff returns Polygon[{{160., 465.66}, {299.832, 708.}, {228.998, 708.}, {160., 588.451}}] directly. Commented Oct 30, 2017 at 16:47
• I am using version 10.4.1.0. Version 11.2 sounds better! Commented Oct 30, 2017 at 16:49

You obtain the actual region with R = BoundaryDiscretizeRegion[regionDiff, MaxCellMeasure -> 100000] or R = BoundaryDiscretizeRegion[regionDiff, Method -> "Boolean"] (somehow depending on the version of Mathematica).

Afterwards, you can access properties of the MeshRegion R like with any other MeshRegions. For example, you obtain the coordinates with MeshCoordinates[R].

• I just tried this with the example Polygons and it gave me a list of 1752 points. The difference region is a quadrilateral. Commented Oct 30, 2017 at 16:53
• @Frobryo - try MeshPrimitives[BoundaryDiscretizeRegion@regionDiff, 2] Commented Oct 30, 2017 at 17:07
• That works! To an extent. It's still giving more points than necessary (47 in the example), but they're all on the edge of the polygon and include the vertices, at least. Commented Oct 30, 2017 at 17:11
• You can prevent subdivision by cranking up the value of MaxCellMeasure. Like this: MeshPrimitives[ BoundaryDiscretizeRegion[regionDiff, MaxCellMeasure -> 100000], 2] Commented Oct 30, 2017 at 17:17
• @Frobryo - this is odd. When I use your example definition of regionDiff and the BoundaryDiscretizeRegion, the result is a Polygon with four points, in version 10.3.1 Commented Oct 30, 2017 at 17:17

In old versions (e.g. 10.4.1), you can use the undocumented function GraphicsPolygonUtilsPolygonComplement[]:

region1 = Polygon[{{310, 577.315}, {310, 708}, {228.998, 708},
{160, 588.451}, {160, 404}, {210.065, 404}}];
region2 = Polygon[{{101.341, 364.}, {330., 187.811}, {558.659, 364.}, {330., 760.283}}];
regionDiff = GraphicsPolygonUtilsPolygonComplement[region1, region2];

Graphics[{{Blue, region2}, {Red, region1}, {Green, regionDiff}}]