# How do I define a periodic region?

I'm trying to create a region of "thick" grid-lines, like so:

GRID = ImplicitRegion[((0 <= x <= 1 || 2 <= x <= 3 || 4 <= x <= 5 || 6 <= x <= 7 ||
8 <= x <= 9) || (0 <= y <= 1 || 2 <= y <= 3 || 4 <= y <= 5 ||
6 <= y <= 7 || 8 <= y <= 9)), {{x, 0, 9}, {y, 0, 9}}];


which with RegionPlot[GRID] produces However, I would like to be able to make my grid an arbitrary size, and arbitrary thickness. So far I have tried using

GRID2 = ImplicitRegion[Mod[x, 5] <= 1 || Mod[y, 5] <= 1, {{x, -10, 10}, {y, -10, 10}}]


but when I try to plot this, Mathematica tells me it's an invalid region to plot. I've also tried Floor-ing the x and y prior to Mod-ing, but it makes no difference. Are there any suggestions on a better way of doing this?

EDIT: It's probably worth pointing out that I plan on using this region as the domain specification of a ParametricPlot3D.

r = N @ ImplicitRegion[
Sin[x Pi] > 0 || Sin[y Pi] > 0,
{{x, 0, 9}, {y, 0, 9}}
]

RegionPlot @ r r3 = N @ ImplicitRegion[
Sin[x Pi] > 0 || Sin[y Pi] > 0 || Sin[z Pi] > 0,
{{x, 0, 9}, {y, 0, 9}, {z, 0, 9}}
]

RegionPlot3D[r3, PlotStyle -> [email protected]] So you can play with translation and scaling with:

Sin[2 x Pi] > 0 || Sin[.5 (y + 1) Pi] > 0 • Also works with SquareWave[x/2] > 0 || SquareWave[y/2] > 0, but the timings are horrible - 24s vs 0.4s for the Sin version.
– shrx
Jan 24, 2016 at 8:26
• The meshes are different too: i.stack.imgur.com/0WeFJ.png
– shrx
Jan 24, 2016 at 8:33
• @shrx Can't make that work on 10.3.1: ImplicitRegion[ SquareWave[x/2] > 0 || SquareWave[y/2] > 0, {{x, 0, 9}, {y, 0, 9}}] and the dense mesh you see for SquareWave is there for Sin appraoch.
– Kuba
Jan 24, 2016 at 8:37
• interesting, seems like a regression. I have 10.2.0 on OS X.
– shrx
Jan 24, 2016 at 9:08

Here is an idea based on graphics primitives instead of mathematical inequalities.

columnWidth = 1;
regionSize = 10;
holes = Table[
Rectangle[{x, y}, {x + columnWidth, y + columnWidth}],
{x, columnWidth, regionSize, 2 columnWidth},
{y, columnWidth, regionSize, 2 columnWidth}
];
holes // Graphics Now we subtract these squares from a larger square that covers all of the area:

RegionDifference[
Rectangle[{0, 0}, {regionSize + columnWidth, regionSize + columnWidth}],
RegionUnion[holes]
] // RegionPlot A bit late, but here's how the Mod[] version should have been implemented:

ir = ImplicitRegion[! (1 < Mod[x, 2] < 2 && 1 < Mod[y, 2] < 2), {{x, 0, 9}, {y, 0, 9}}];
RegionPlot[ir] A 3D version, just like in Kuba's answer:

ir3 = ImplicitRegion[! (1 < Mod[x, 2] < 2 && 1 < Mod[y, 2] < 2 && 1 < Mod[z, 2] < 2),
{{x, 0, 9}, {y, 0, 9}, {z, 0, 9}}];
RegionPlot3D[ir3, PlotStyle -> Opacity[.5]] It's probably worth pointing out that I plan on using this region as the domain specification of a ParametricPlot3D.

In such a case, it is often more efficient to do preprocessing with (Boundary)DiscretizeRegion[] before using it as a plotting region.