I have two very simple polygons.
a = Polygon[{{2, 0}, {2, 100}, {502, 100}, {502, 0}, {2, 0}}]
b = Polygon[{{202, -200}, {202, 296}, {300, 296}, {300, -200}, {202, -200}}]
I wish to produce a new polygon which (for example) describes their union as pictured above, but is expressed as a single Polygon[]
instance. In this simple case, I can create it by-hand as:
c = Polygon[{
{2, 0}, {2, 100}, {202, 100}, {202, 296}, {300, 296},
{300, 100}, {502, 100}, {502, 0}, {300, 0}, {300, -200},
{202, -200}, {202, 0}, {2, 0}}}]
Of course, I wish to obtain this polygon automatically.
Unfortunately RegionUnion
above returns a BooleanRegion
:
This is despite some other region functions like RegionIntersection
returning a Polygon
.
In fact, I have difficulty predicting what families of polygons will return Polygon
(or other acceptable symbols like Triangle
) vs BooleanRegion
when given to functions RegionIntersection
, RegionUnion
, RegionDifference
.
How can I convert a BooleanRegion
of two simple Polygon
s into a Polygon
(or a list thereof)?