Fractal Tikz - Poeira Cantor

Fractal Tikz - Poeira Cantor

Alguém pode me ajudar a desenhar o seguinte fractal no Tikz? insira a descrição da imagem aqui

Aqui começamos com o quadrado unitário, dividimos-o em 16 quadrados iguais e removemos 12 deles - deixando 4 dispostos como visto. O processo é repetido nos quadrados restantes e assim por diante.

Tenho certeza que preciso usar algo semelhante aAninhando decorações fractal tikzmas não sou bom o suficiente em TeX para compilar o código sozinho.

Agradeço antecipadamente.

Meu código até agora:

 \newcommand{\dust}[1]{
     \foreach \i in {1,...,#1}{decorate\{}
     (0,0)--(1,1)
     \foreach \i in {1,...,#1}{\}};

      SOMETHING IN HERE (DON'T KNOW)
 }

 \begin{tikzpicture}
     \path (0,0) pic {dust=5};
 \end{tikzpicture}

Responder1

É um bom exercício do sistema Lindenmayer.

\documentclass[border=9,tikz]{standalone}
\usetikzlibrary{lindenmayersystems}
\begin{document}
\pgfdeclarelindenmayersystem{Cantor dust}{
    \symbol{S}{\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\pgflsystemcurrentstep}{\pgflsystemcurrentstep}}}
    \symbol{U}{\pgftransformyshift{\pgflsystemcurrentstep}}
    \symbol{R}{\pgftransformxshift{\pgflsystemcurrentstep}}
    \rule{S -> [UUSURRS][RSRRUS]}
    \rule{U -> UUUU}
    \rule{R -> RRRR}
}
\tikz;
\tikz\fill[lindenmayer system={Cantor dust,axiom=S,step=320pt,order=1}]lindenmayer system;
\tikz\fill[lindenmayer system={Cantor dust,axiom=S,step= 80pt,order=2}]lindenmayer system;
\tikz\fill[lindenmayer system={Cantor dust,axiom=S,step= 20pt,order=3}]lindenmayer system;
\tikz\fill[lindenmayer system={Cantor dust,axiom=S,step=  5pt,order=4}]lindenmayer system;
\end{document}

Responder2

Acabei de descobrir este tópico, que estava relacionado a outro, mais recente. Pode ser considerada uma aplicação de programação recursiva, para a qualMetaPostgeralmente é bem adequado. Então aqui está uma solução MetaPost, para quem pode interessar.

def cantor_dust(expr x, y, d, n) = 
    if n > 0:
        cantor_dust(x+.25d, y, .25d, n-1);
        cantor_dust(x+.75d, y+.25d, .25d, n-1);
        cantor_dust(x+.5d, y+.75d, .25d, n-1);
        cantor_dust(x, y+.5d, .25d,  n-1);
    else: fill (x, y) -- (x+d, y) -- (x+d, y+d) -- (x, y+d) -- cycle; fi
enddef;
beginfig(1);
    for i = 0 upto 4:
        draw image(cantor_dust(0, 0, 4cm, i)) shifted (4.25cm*i, 0);
    endfor;
endfig;
end.

insira a descrição da imagem aqui

informação relacionada