# Reiterative Graphics- Fractals and Isometries

I am trying to reiterate a program on mathematica.

Say, I begin with a circle partitioned into 3 symmetric regions. The code is below:

R0 = {{Cos[2 Pi/3], -Sin[2 Pi/3]}, {Sin[2 Pi/3], Cos[2 Pi/3]}};
V1 = {{-Cos[Pi/6]}, {-Sin[Pi/6]}};
R1 = R0.V1;
R2 = R0.R1;
X1 = V1[[1]][[1]];
Y1 = V1[[2]][[1]];
X2 = R1[[1]][[1]];
Y2 = R1[[2]][[1]];
X3 = R2[[1]][[1]];
Y3 = R2[[2]][[1]];
C1 = {Opacity[.2], Yellow, Disk[{0, 0}, 1, {0, 2 Pi/3}]};
C2 = {Opacity[.2], Orange, Disk[{0, 0}, 1, {2 Pi/3, 2*2 Pi/3}]};
C3 = {Opacity[.2], Blue, Disk[{0, 0}, 1, {2*2 Pi/3, 2 Pi}]};
T1 = Graphics[Translate[C1, {0, 0}]];
T2 = Graphics[Translate[C2, {0, 0}]];
T3 = Graphics[Translate[C3, {0, 0}]];
Show[T1, T2, T3, PlotRange -> All, Axes -> True]


And I have this image:

Suppose I fix the boundaries of these regions and translate the parts using a symmetric translation. I now utilize the original V1 vector for this translation, which corresponds to the first vector being a translation on V1 and each part gets translated by the same vector rotated by $2 \pi /3$ successively. My updated code looks like this:

R0 = {{Cos[2 Pi/3], -Sin[2 Pi/3]}, {Sin[2 Pi/3], Cos[2 Pi/3]}};
V1 = {{-Cos[Pi/6]}, {-Sin[Pi/6]}};
R1 = R0.V1;
R2 = R0.R1;
X1 = V1[[1]][[1]];
Y1 = V1[[2]][[1]];
X2 = R1[[1]][[1]];
Y2 = R1[[2]][[1]];
X3 = R2[[1]][[1]];
Y3 = R2[[2]][[1]];
C1 = {Opacity[.2], Yellow, Disk[{0, 0}, 1, {0, 2 Pi/3}]};
C2 = {Opacity[.2], Orange, Disk[{0, 0}, 1, {2 Pi/3, 2*2 Pi/3}]};
C3 = {Opacity[.2], Blue, Disk[{0, 0}, 1, {2*2 Pi/3, 2 Pi}]};
T1 = Graphics[Translate[C1, {X1, Y1}]];
T2 = Graphics[Translate[C2, {X2, Y2}]];
T3 = Graphics[Translate[C3, {X3, Y3}]];
Show[T1, T2, T3, PlotRange -> All, Axes -> True]


And we have this image:

Now, what I want to do is to repeat the translation, this time only taking parts of the new pieces that lie inside the original boundaries. I want to do this two ways. The first is to just repeat the translation on the new pieces that lie on the original boundary as the first image. The other way is to do this while truncating the pieces that lie outside the original boundary. The result should be a fractal like image. How could I do this?

## 1 Answer

Fo this types of fractals, most generally you should make use of AffineTransform. Your transformations are too specific and detailed, so I just show here a few relevant stating examples, as I see no help is coming. And you can use these methods to work out your detailed transformations.

## Direct iteration

Define an affine transform

atCircle = AffineTransform[{{.184, -.6}, {1.16, .6}}]


then iterate to get replication on different scales:

Graphics[NestList[GeometricTransformation[#,atCircle]&,Circle[{2, 2}], 30]]


## Recursive definitions

Use recursive function definition to compute an iterated function system (IFS) applied to graphics primitives:

TransformIFS[g_, IFS[l_List]] :=
Module[{prim = First[g], h = Head[g]},
t = Table[GeometricTransformation[prim, l[[i]]], {i, Length[l]}];
h[t]];
TransformIFS[g_, ifs_IFS, 0] := g;
TransformIFS[g_, ifs_IFS, 1] := TransformIFS[g, ifs];
TransformIFS[g_, ifs_IFS, n_Integer?Positive] :=
TransformIFS[TransformIFS[g, ifs], ifs, n - 1];


Apply to a square to get Sierpiński gasket:

SierpinskiGasket = With[{dm = DiagonalMatrix[{1, 1}/2]},
IFS[{AffineTransform[{dm}], AffineTransform[{dm, {1/2, 0}}],
AffineTransform[{dm, {0.25, 0.433}}]}]];

Table[TransformIFS[Graphics[Rectangle[]],SierpinskiGasket,n],{n,0,5}]


• Thanks, actually I was trying to take the intersection of the two regions in order to be able to re-translate each piece, however I am getting an error saying that the regions are not specified. – Hyperbolic Cake Sep 18 '18 at 4:10