Last active
December 15, 2015 21:52
-
-
Save butchi/59d10ab09c140e476c75 to your computer and use it in GitHub Desktop.
シェルピンスキーのカーペット(Mathematicaショートフラクタルシリーズ) ref: http://qiita.com/butchi_y/items/3b164bb8e25dad7763cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sierpinskiCarpet[x_] := ArrayFlatten[x /. { | |
0 -> { | |
{0, 0, 0}, | |
{0, 0, 0}, | |
{0, 0, 0} | |
}, | |
1 -> { | |
{1, 1, 1}, | |
{1, 0, 1}, | |
{1, 1, 1} | |
} | |
}] | |
ArrayPlot[Nest[sierpinskiCarpet, 1, 5], PixelConstrained -> 1, Frame -> False] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In[1] = sierpinskiCarpet[1] | |
Out[1] = {{1, 1, 1}, {1, 0, 1}, {1, 1, 1}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 -> { | |
{1, 1, 1}, | |
{1, 0, 1}, | |
{1, 1, 1} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In[2] = sierpinskiCarpet[sierpinskiCarpet[1]] | |
Out[2] = {{1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 1, 1, 0, 1, 1, 0, 1}, {1, 1, 1, | |
1, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 0, 0, 1, 1, 1}, {1, 0, 1, 0, 0, 0, | |
1, 0, 1}, {1, 1, 1, 0, 0, 0, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, | |
1}, {1, 0, 1, 1, 0, 1, 1, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArrayPlot[sierpinskiCarpet[sierpinskiCarpet[1]]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}, {{1, 1, 1}, {1, 0, 1}, {1, 1, | |
1}}, {{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}}, {{{1, 1, 1}, {1, 0, | |
1}, {1, 1, 1}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, {{1, 1, 1}, {1, | |
0, 1}, {1, 1, 1}}}, {{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}, {{1, 1, | |
1}, {1, 0, 1}, {1, 1, 1}}, {{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArrayPlot[Nest[ArrayFlatten[#/.{0->ConstantArray[0,{3,3}],1->{{1,1,1},{1,0,1},{1,1,1}}}]&,1,5]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArrayPlot[ | |
Nest[ | |
ArrayFlatten[ | |
#/.{ | |
0 -> ConstantArray[0,{3,3}], | |
1 -> {{1,1,1},{1,0,1},{1,1,1}} | |
} | |
]&, | |
1, | |
5 | |
], | |
PixelConstrained->1, | |
Frame->False | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Graphics[Raster[Nest[ | |
ArrayFlatten[ | |
#/.{ | |
1 -> ConstantArray[1,{3,3}], | |
0 -> {{0,0,0},{0,1,0},{0,0,0}} | |
} | |
]&, | |
0, | |
5 | |
]]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment