Re: Polygon with holes
- To: mathgroup at smc.vnet.net
- Subject: [mg97330] Re: Polygon with holes
- From: ragfield <ragfield at gmail.com>
- Date: Wed, 11 Mar 2009 04:22:27 -0500 (EST)
- References: <gp5fn9$9mc$1@smc.vnet.net>
On Mar 10, 5:34 am, Harrie Kraai <hakr... at xs4all.nl> wrote: > Does anyone know of a facility for Polygons (graphics) with holes inside? > I guess there is no such thing as an oriented polygon in Mathematica? > Or a polygon consisting of disjoint lines (inner and outer contours, > clockwise and counterclockwise)? > > I can see that it is possible to connect outer and inner contours using > a dummy line, but that is not so easy to program in a generic way. This is currently the only way to achieve the desired affect. MultiContourPolygon[polys_List] := Module[ {contours = Append[#, First[#]] & /@ polys}, { Polygon@Join[Join @@ contours, Reverse[First /@ contours]], Line[contours] } ] Graphics@MultiContourPolygon[{{{0, 0}, {0, 1}, {1, 1}, {1, 0}}, {{.25, .25}, {.75, .25}, {.75, .75}, {.25, .75}}, {{.4, \ .4}, {.6, .4}, {.6, .6}, {.4, .6}}}] > Solutions such as creating an artificial hole by another Polygon in the > background colour are not really acceptable. > > Polygon's with holes would be very useful for maps etc. Agreed. -Rob