Re: Polygon with holes

• To: mathgroup at smc.vnet.net
• Subject: [mg97405] Re: Polygon with holes
• From: Harrie Kraai <hakraai at xs4all.nl>
• Date: Thu, 12 Mar 2009 05:42:38 -0500 (EST)
• References: <gp5fn9\$9mc\$1@smc.vnet.net> <gp7vsh\$1cv\$1@smc.vnet.net>

ragfield wrote:
> 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}}}]
>

Hi Rob,

Thanks for this suggestion. However, (as you are porbably aware) it does
not work so easily for arbitrary polygons. The connection between inner
and outer contours is made by a straight line. A general algorithm would
have to select the points to be connected and make sure that the
connection itself does not intersect the contours. There should also be
a check on the orientations. Making two or more holes would complicate
things further.

As I expected there seems to be no simple facility available. This could
be a feature request for wolfram. How do I submit one?

HK

>> 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.

T

>
> -Rob
>

• Prev by Date: Re: Using Select
• Next by Date: Re: Re: Mathematica 7.0.1.0 and some General Comments
• Previous by thread: Re: Polygon with holes
• Next by thread: Re: Polygon with holes