Convex Polygons with Their Insides Chomped Out
- To: mathgroup at smc.vnet.net
- Subject: [mg6566] Convex Polygons with Their Insides Chomped Out
- From: "Seth J. Chandler" <SChandler at uh.edu>
- Date: Tue, 1 Apr 1997 19:01:01 -0500 (EST)
- Organization: University of Houston Law Cen
- Sender: owner-wri-mathgroup at wolfram.com
Does anyone have a good Mathematica algorithm for converting a Polygon expression (where the polygon has three dimensions and is known to be convex) into one or more Polygon expressions which, when displayed with a Graphics3D wrapper, look like the exterior skeleton of the original polygon. Put differently, I want an attractive "wire frame" of the Polygon where the "wires" are themselves polygons and not lines. To give you some idea what I am talking about, here is my inelegant algorithm which (a) just feels wrong and (b) doesn't work for Polygons with an odd number of sides. To use this algorithm, write Polygon[Table[{x[i],y[i],z[i]},{i,1,4}]]/.exterior[0.1] exterior[z_]:= RuleDelayed[p_Polygon, Module[{c,d,i,pts,intsequence,extsequence,thesigns}, pts=First[p]; c=Module[{ppts},ppts=Partition[pts,Floor[Length[pts]/2]]; Last[ppts]-First[ppts]]; thesigns= Module[{x},x=Floor[Length[pts]/2]; Join[Table[1,{i,1,x}],Table[-1,{i,1,Length[pts]-x}]]]; d=Map[Sqrt[#.#]&,c]; i=MapThread[#1+z*#2*#3*#4&,{pts,Flatten[{c,c},1],Flatten[{d,d},1], thesigns}]; extsequence=Partition[Append[pts,pts[[1]]],2,1]; intsequence=Reverse/@Partition[Append[i,i[[1]]],2,1]; MapThread[Polygon[Join[#1,#2]]&,{extsequence,intsequence}] ]]