Nested Polygon

Author

Eric W. Weisstein
February 10, 2011

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Graphics/NestedPolygon.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/NestedPolygon.html.

©2011 Wolfram Research, Inc. except for portions noted otherwise

Code

NestedSquare[n_]:=Polygon/@( {{{-1,-1},{0,-1},{-1,0}},{{0,-1},{1,-1},{1,0}},{{1,1},{0,1},{1,0}},{{-1,1},{0,1},{-1,0}}}/2^n)

NestedPolygon[n_,its_,th_:0,opts___?OptionQ]:=Module[
{
colorfn=ColorFunction/.{opts}/.{ColorFunction->(GrayLevel[Mod[#,2]]&)}
},
Table[{colorfn[k],Polygon@Table[Cos[Pi/n]^k Through[{Cos,Sin}[th+2Pi(i+Mod[k,2]/2)/n]],{i,0,n-1}]},{k,0,its-1}]
]

Graphics

V5

Show[GraphicsArray[
{
Table[Graphics[
NestedPolygon[n,5n],
AspectRatio->Automatic,PlotRange->All],
{n,3,7}],
Table[Graphics[
NestedPolygon[n,5n,ColorFunction->(Hue[#/(1.5n)]&)],
AspectRatio->Automatic,PlotRange->All],
{n,3,7}]
}
]]

V6

GraphicsGrid[
{
Table[Graphics[NestedPolygon[n,5n,0]],{n,3,7}],
Table[Graphics[NestedPolygon[n,5n,0,ColorFunction->(Hue[#/(1.5n)]&)]],{n,3,7}]
}
]

Animation

<<Utilities`GIF`

Export[gifs<>"nestpol.gif",movie=Show/@Table[Graphics[
NestedPolygon[8,n],
AspectRatio->Automatic,PlotRange->All],{n,1,50,2}]]//Timing

Show[GraphicsArray[Partition[Take[movie,12],4]]]

Area of Nested Square

Sum[((((-1))^n)/(2^n)),{n,0,∞}]

(1/2)Sum[(1/(4^n)),{n,0,∞}]

Graphics[NestedPolygon[4,1,π/4]]

Norm[{0,1}-{1,0}]

Graphics[NestedPolygon[4,3,π/4]]

a0=Count[Flatten[Rasterize[Graphics[NestedPolygon[4,1,π/4]]][[1,1]]],255]

a=Count[Flatten[Rasterize[Graphics[NestedPolygon[4,20,π/4]]][[1,1]]],255]

Graphics[NestedPolygon[4,20,π/4]]