Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ClearAll[f];
- f@{{1, 1, _}, {1, _, _}, {_, _, _}} = 0;
- f@{{_, 1, 1}, {_, _, 1}, {_, _, _}} = 0;
- f@{{_, _, _}, {_, _, 1}, {_, 1, 1}} = 0;
- f@{{_, _, _}, {1, _, _}, {1, 1, _}} = 0;
- f@{_, {_, x_, _}, _} := If[Random[] < 0.1, 1, x];
- del = # //. {x___, 0, 1, 1, 0, z___} :> {x, 0, 0, 0, 0, z} &;
- ca = Unitize@SelectComponents[#, Large] &@
- MorphologicalComponents[#, CornerNeighbors -> False] &@
- ArrayPad[#, -1] &@del@Transpose@del@ArrayPad[#, 1] &@
- CellularAutomaton[{f[#] &, {}, {1, 1}}, #, {{200}}][[1]] &;
- res = Nest[ca, ConstantArray[0, {30, 30}], 4];
- labels = Position[#, {_, {0, 1, 1}, _} | {{_, 0, _}, {_, 1, _}, {_,
- 1, _}}, {2}] &@Partition[#, {3, 3}, 1] &@
- ArrayPad[res, 1, Padding -> "Periodic"];
- n = 20;
- texture =
- ImageResize[#, Scaled[5]] &@
- Rasterize@
- ArrayPlot[1 - res, Mesh -> All, Frame -> False, MeshStyle -> Black,
- Epilog ->
- MapIndexed[
- Text[Style[#2[[1]], 9],
- n {#[[2]] - 0.95, Length@res - #[[1]] + 0.95}, {-1, 1}] &,
- labels], PixelConstrained -> n]
- r = 1.5;
- ParametricPlot3D[{Cos[t], Sin[t], Sin[# u]/#} #^2/(r - Cos[# u]) &[
- Sqrt[r^2 - 1]], {t, 0, 2 \[Pi]}, {u, 0, 2 \[Pi]/Sqrt[r^2 - 1]},
- PlotPoints -> 100, Boxed -> False, Axes -> False,
- Lighting -> "Neutral", PlotStyle -> Texture[texture],
- TextureCoordinateScaling -> False,
- TextureCoordinateFunction -> ({#4 + 2, #5 Sqrt[r^2 - 1] - 0.5}/
- 2/\[Pi] &), Mesh -> None]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement