Function Repository Resource:

IteratedAffinePlot

Source Notebook

Plot polygons after iteratively applying a translation, scaling and rotation

Contributed by: Radhika Prasad

ResourceFunction["IteratedAffinePlot"][rules, init]

plots the polygon described by the points init, and the transformed shape after applying the transformation given by rules.

ResourceFunction["IteratedAffinePlot"][rules, init,iter]

plots the polygon described by the points init, and the transformed shape after applying the transformation given by rules, for the number of iterations specified by iter.

Details and Options

init is a list of coordinates describing the initial polygon.
rules is a list of the form {{{x1,y1},s1,θ1},}, where {xi,yi} specifies the coordinates of the centroid of the transformed polygons, si specifies the scaling factors and θi specifies the rotation angles.
iter plots the transformed shapes for the number of iterations as given by iter. It is an optional argument, with the default value being 1. It can take any of the following forms:
nall iterations through n
{{n}}plot only the nth iteration
{n1,n2}plots iterations from n1 through n2
{n1,n2,dn}plots iterations from n1 through n2 in steps of dn
ResourceFunction["IteratedAffinePlot"] accepts all options of Graphics, with the additional option "ShowMarker".
With the default "ShowMarker"True, markers showing the orientation of the transformed polygons are shown.

Examples

Basic Examples (1) 

Show a single iteration of a given set of transformation rules, along with the initial polygon:

In[1]:=
ResourceFunction[
 "IteratedAffinePlot"][{{{1/2, 1/2}, 0.85, 30 \[Degree]}, {{-.1, .5}, .35, 0}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]
Out[1]=

Scope (2) 

Show 5 iterations of a set of transformation rules:

In[2]:=
ResourceFunction[
 "IteratedAffinePlot"][{{{1/2, 1/2}, 0.85, 30 \[Degree]}, {{-.1, .5}, .35, 0}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}, 5]
Out[2]=

Show the fifth through tenth iterations:

In[3]:=
ResourceFunction[
 "IteratedAffinePlot"][{{{1/2, 1/2}, 0.85, 30 \[Degree]}, {{-.1, .5}, .35, 0}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {5, 10}]
Out[3]=

Show the fifth, seventh and ninth iterations:

In[4]:=
ResourceFunction[
 "IteratedAffinePlot"][{{{1/2, 1/2}, 0.85, 30 \[Degree]}, {{-.1, .5}, .35, 0}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {5, 10, 2}]
Out[4]=

Show only the fifth iteration:

In[5]:=
ResourceFunction[
 "IteratedAffinePlot"][{{{1/2, 1/2}, 0.85, 30 \[Degree]}, {{-.1, .5}, .35, 0}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{5}}]
Out[5]=

Use Graphics options:

In[6]:=
ResourceFunction[
 "IteratedAffinePlot"][{{{1/2, 1/2}, 0.85, \[Pi]/6}, {{-.1, .5}, .35, 0}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{5}}, Background -> LightBlue, Frame -> True]
Out[6]=

Options (1) 

ShowMarker (1) 

Set "ShowMarker"False to omit the markers in the results:

In[7]:=
ResourceFunction[
 "IteratedAffinePlot"][{{{1/2, 1/2}, 0.85, 30 \[Degree]}, {{-.1, .5}, .35, 0}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {5, 10, 2}, "ShowMarker" -> False]
Out[7]=

Applications (2) 

The Sierpinski triangle:

In[8]:=
ResourceFunction[
  "IteratedAffinePlot"][{{{1/4, 1/(4 Sqrt[3])}, 0.5, 0}, {{1/2, 1/Sqrt[3]}, 0.5, 0}, {{3/4, 1/(4 Sqrt[3])}, 0.5, 0}}, {{0, 0}, {1, 0}, {1/2, Sqrt[3]/2}}, {{4}}, "ShowMarker" -> False] // First
Out[8]=

Compare with the result of SierpinskiMesh:

In[9]:=
SierpinskiMesh[3]
Out[9]=

The Sierpinski carpet:

In[10]:=
ResourceFunction[
  "IteratedAffinePlot"][{{{1/6, 5/6}, 1/3, 0}, {{1/2, 5/6}, 1/3, 0}, {{5/6, 5/6}, 1/3, 0}, {{1/6, 1/2}, 1/3, 0}, {{5/6, 1/2}, 1/3, 0}, {{1/6, 1/6}, 1/3, 0}, {{1/2, 1/6}, 1/3, 0}, {{5/6, 1/6}, 1/3, 0}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{4}}, "ShowMarker" -> False] // First
Out[10]=

Compare with the result of MengerMesh:

In[11]:=
MengerMesh[3]
Out[11]=

Publisher

WolframSpecialProjects

Version History

  • 1.0.0 – 17 May 2021

Source Metadata

Related Resources

License Information