Primeira vez aqui? Seja bem vindo e cheque o FAQ!
x

Como gerar o Carpete de Sierpinski usando contrações?

+1 voto
49 visitas
perguntada Jul 11, 2016 em Matemática por Camila (31 pontos)  
Compartilhe

1 Resposta

0 votos
respondida Jul 11, 2016 por Camila (31 pontos)  

Utilizando a ideia apresentada aqui para o Triângulo de Sierpinski, o Carpete de Sierpinski pode ser gerado através de uma contração \(C\) definida como a união dos seguintes operadores:

\[C_1(x,y)=\frac{1}{3}\left[\begin{array}{c} x \\ y \\ \end{array}\right]\]

\[C_2(x,y)=\frac{1}{3}\left[\begin{array}{c} x \\ y \\ \end{array}\right]+\left[\begin{array}{c} 0 \\ \frac{2}{3} \\ \end{array}\right]\]

\[C_3(x,y)=\frac{1}{3}\left[\begin{array}{c} x \\ y \\ \end{array}\right]+\left[\begin{array}{c} 0 \\ \frac{1}{3} \\ \end{array}\right]\]

\[C_4(x,y)=\frac{1}{3}\left[\begin{array}{c} x \\ y \\ \end{array}\right]+\left[\begin{array}{c} \frac{2}{3} \\ 0 \\ \end{array}\right]\]

\[C_5(x,y)=\frac{1}{3}\left[\begin{array}{c} x \\ y \\ \end{array}\right]+\left[\begin{array}{c} \frac{1}{3} \\ 0 \\ \end{array}\right]\]

\[C_6(x,y)=\frac{1}{3}\left[\begin{array}{c} x \\ y \\ \end{array}\right]+\left[\begin{array}{c} \frac{2}{3} \\ \frac{2}{3} \\ \end{array}\right]\]

\[C_7(x,y)=\frac{1}{3}\left[\begin{array}{c} x \\ y \\ \end{array}\right]+\left[\begin{array}{c} \frac{1}{3} \\ \frac{2}{3} \\ \end{array}\right]\]

\[C_8(x,y)=\frac{1}{3}\left[\begin{array}{c} x \\ y \\ \end{array}\right]+\left[\begin{array}{c} \frac{2}{3} \\ \frac{1}{3} \\ \end{array}\right]\]

Após 4 iterações, temos:

A imagem será apresentada aqui.

A imagem acima foi gerada com a seguinte implementação usando python:

import numpy as np
import matplotlib.pyplot as plt

def generatePlane(N):
    plane=np.empty([N*N,2]) 
    count=-1
    for i in range(N):
        for j in range(N):
            count=count+1
            plane[count,0]=1.0*i/N
            plane[count,1]=1.0*j/N
    return plane

def contractionSierpinski(plane):
    [m,n]=np.shape(plane)
    newRegion=np.empty([8*m,2])
    count=-1
    for i in range(m):
        count=count+1
        newRegion[count,0]=(1.0*plane[i,0])/3.0 
        newRegion[count,1]=(1.0*plane[i,1])/3.0 

    for i in range(m):
        count=count+1
        newRegion[count,0]=(1.0*plane[i,0])/3.0
        newRegion[count,1]=(1.0*plane[i,1])/3.0+2.0/3.0 

    for i in range(m):
        count=count+1
        newRegion[count,0]=(1.0*plane[i,0])/3.0
        newRegion[count,1]=(1.0*plane[i,1])/3.0+1.0/3.0 

    for i in range(m):
        count=count+1
        newRegion[count,0]=(1.0*plane[i,0])/3.0+2.0/3.0
        newRegion[count,1]=(1.0*plane[i,1])/3.0

    for i in range(m):
        count=count+1
        newRegion[count,0]=(1.0*plane[i,0])/3.0+1.0/3.0
        newRegion[count,1]=(1.0*plane[i,1])/3.0

    for i in range(m):
        count=count+1
        newRegion[count,0]=(1.0*plane[i,0])/3.0+2.0/3.0
        newRegion[count,1]=(1.0*plane[i,1])/3.0+2.0/3.0

    for i in range(m):
        count=count+1
        newRegion[count,0]=(1.0*plane[i,0])/3.0+1.0/3.0
        newRegion[count,1]=(1.0*plane[i,1])/3.0+2.0/3.0

    for i in range(m):
        count=count+1
        newRegion[count,0]=(1.0*plane[i,0])/3.0+2.0/3.0
        newRegion[count,1]=(1.0*plane[i,1])/3.0+1.0/3.0
    return newRegion

if __name__ == '__main__':

    N=100
    plane=generatePlane(N)

    #iteration 1
    region=contractionSierpinski(plane)
    #iteration 2
    region=contractionSierpinski(region)
    #iteration 3
    region=contractionSierpinski(region)
    #iteration 4
    region=contractionSierpinski(region)

    fig = plt.figure()
    ax = fig.add_subplot(111)
    fig.hold()
    ax.plot(region[:,0],region[:,1],'c',markersize=10, markeredgewidth=0)
    ax.set_ylabel('y')
    ax.set_xlabel('x')
...