I would like to implement an algorithm for designing this non-symmorphic lattice
This has a Glide reflection axis runs northeast-southwest.
I would like to implement an algorithm for designing this non-symmorphic lattice
This has a Glide reflection axis runs northeast-southwest.
First we recognize that we might not want to work with rectangles, but with tile elements that look like this.
tile =
{Line[{{0, 0}, {1, 0}}], Line[{{0, 1}, {2, 1}}],
Line[{{0, 2}, {2, 2}}], Line[{{0, 1}, {0, 2}}],
Line[{{1, 0}, {1, 1}}], Line[{{2, 0}, {2, 1}}],
Line[{{2, 0}, {2, 2}}], Line[{{3, 0}, {3, 2}}],
Line[{{4, 1}, {4, 2}}], Line[{{2, 0}, {4, 0}}],
Line[{{3, 1}, {4, 1}}], Line[{{2, 2}, {3, 2}}]};
Graphics[tile]
Given that we need two translation functions.
t0 = Translate[tile, {4 #1, 2 #2}] &;
t2 = Translate[tile, {2 + 4 #1, 2 #2}] &;
Now we can draw the tiling.
Graphics[Function[n, {t0[#, n], t2[#, 1 + n]} & /@ Range[0, 4]] /@ Range[0, 8, 2]]
This is a step by step setup for a textured image.
We can generate rectangles at proper distance with:
Graphics[{EdgeForm[Thick], White,
Table[Rectangle[{i, 0}, {i + 2, 1}], {i, 0, 6, 4}]}]
Then lets add a vertical rectangle:
Graphics[{EdgeForm[Thick], White,
Table[{Rectangle[{i, 0}, {i + 2, 1}],
Rectangle[{i + 2, -1}, {i + 3, 1}]}, {i, 0, 6, 4}]}]
The horizontal rectangle to the top and right of the initial one, is given by increasing both x
and y
by 1
, for which we'll use a new iterator:
{Rectangle[{i + j, j}, {i + j + 2, j + 1}],
Rectangle[{i + 2 + j, -1 + j}, {i + 3 + j, 1 + j}]}
Now generate a function which will do everything including a good plotting range:
tiles[n_] :=
Graphics[{EdgeForm[Thick], White,
Table[{Rectangle[{i + j, j}, {i + j + 2, j + 1}],
Rectangle[{i + 2 + j, -1 + j}, {i + 3 + j, 1 + j}]}, {i, 0,
2n, 4}, {j, n}]}, PlotRange -> {{n, 2+ 2n}, {1, n}}]
If you want to generate an actual textured tileset, you need to use polygons:
tileim = Import["https://i.imgsafe.org/d2eee03f00.png"];
tilesG[n_] :=
Graphics[{Texture[tileim],
Table[{Polygon[{{i + j, j}, {i + j, j + 1}, {i + j + 2,
j + 1}, {i + j + 2, j}},
VertexTextureCoordinates -> {{0, 1}, {1, 1}, {1, 0}, {0, 0}}],
Polygon[{{i + 2 + j, -1 + j}, {i + 2 + j, 1 + j}, {i + 3 + j,
1 + j}, {i + 3 + j, -1 + j}},
VertexTextureCoordinates -> {{0, 0}, {0, 1}, {1, 1}, {1,
0}}]}, {i, 0, 2 n, 4}, {j, n}]},
PlotRange -> {{n, 2 + 2 n}, {1, n}}]
tilesG[8]
VertexTextureCoordinates
setting of the first set of Polygon[]
s into VertexTextureCoordinates -> {{0, 1}, {1, 1}, {1, 0}, {0, 0}}
.
$\endgroup$
Commented
Dec 10, 2016 at 10:15
tile.png
to imgur, and then use Import[]
to get the image from within Mathematica.
$\endgroup$
Commented
Dec 11, 2016 at 10:43