Dear all,
I am trying to draw a set of polygons in Mathematica (version 8). These polygons intersect, and I do not mind per se that Mathematica (apparently) has no implemented function to compute the union of a set of polygons, as I can always draw all the polygons combined and will get what I need (it might be inefficient, but that is barely noticable). However, the problems start once I set the opacity of the polygons below 1.
Here's an example: The polygons I want to plot are
Polygon[{{0, 0}, {2, 0}, {0, 2}}]
and
Polygon[{{0, 0}, {2, 1}, {1, 2}}].
Then
Graphics[Polygon[{{{0, 0}, {2, 0}, {0, 2}}, {{0, 0}, {2, 1}, {1, 2}}}]]
works fine.
However, once I change the setting for the opacity, such as
Graphics[{Opacity[.5],
Polygon[{{{0, 0}, {2, 0}, {0, 2}}, {{0, 0}, {2, 1}, {1, 2}}}]
}]
the intersection of the polygons looks different, as it overlays the two individual polygons.
This effect is usually a nice desirable feature. However, in my case, I would like to draw the union of the two polygons, and then apply the opacity to the entire union, treating this union as a single polygon.
I have tried to create a graphics object without opacity settings, and then apply opacity to this graphics object, but it didn't work for any of the ways i tried.
Do you have any ideas how I could accomplish it?
Thanks in advance.