I am trying to draw the iterations of the IFS in which from an interval middle third is removed and in the resulting figure left line is shifted 1/6th to the right and right line is shifted 1/6th to the left.
The following code I tried, doesn't seems right from the output image:
cantorRule =
Line[{{a_, n_}, {b_, n_}}] :>
With[{d = b - a,
np = n - 0.1`}, {Line[{{a + d/6, np}, {a + d/3 + d/6, np}}],
Line[{{b - d/3 - d/6, np}, {b - d/6, np}}]}]
Graphics[{CapForm["Butt"], Thickness[.05],
Flatten@NestList[# /. cantorRule &, Line[{{0., 0}, {1., 0}}], 6]}]
In the above code how to change the color of the left shifting and right shifting lines different in each step.
Update:
cantorRule =
Line[{{a_, n_}, {b_, n_}}] :>
With[{d = b - a,
np = n - 0.1`}, {Line[{{a + d/6, np}, {a + d/3 + d/6, np}}],
Line[{{b - d/3 - d/6, np}, {b - d/6, np}}]}]
Graphics[{CapForm["Butt"], Thickness[.05],
Flatten@NestList[# /. cantorRule &, Line[{{0., 0}, {1., 0}}], 6]}]
I changed the code as above and got this image: How to get the end points of each intervals labelled?
CantorMesh
is only doing the middle third rule, right? $\endgroup$