Notes

Chapter 5: Two Dimensions and Beyond

Section 7: Systems Based on Constraints


Representing repetitive [2D] patterns

Repetitive patterns are often most conveniently represented as tessellations of rectangles whose corners overlap. Pattern (a) on page 213 can be specified as

{{2, -1, 2, 3}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {1, 0, 0, 0}}}

Given this, a complete nx by ny array filled with this pattern can be constructed from

c[{d1_, d2_, d3_, d4_}, {x_, y_}] := With[{d = d1 d2 + d1 d4 + d3 d4}, Mod[{{d2 x + d4 x + d3 y, d4 x - d1 y}}/d, 1]]

Fill[{dlist_, data_}, {nx_, ny_}] := Array[c[dlist, {##}] &, {nx, ny}] /. Flatten[MapIndexed[c[dlist, Reverse[#2]] #1 &, Reverse[data], {2}], 1]

From Stephen Wolfram: A New Kind of Science [citation]