# Periodically tiling a function

I have a function which creates a hole of varying radius, depth and would like to tile it in x and y.

    Hole[x_, y_, radius_, holefraction_] :=
Which[x^2 + y^2 <= radius, holefraction, x^2 + y^2 > radius, 1]


I have been playing around with the mod[] function, but can't seem to find the right way to rigidly offset the hole by an arbitrary pitch in x and y. If this were in a loop, i would just iterate as x=xrelative+i*pitch, but how would I do the reverse, where I just want to rigidly pattern in x and y?
Alternatively, is there a way to create a 2nd function using this one, and just set periodic boundary conditions in x and y? Thanks!

PeriodicHole[p : {x_, y_}, radius_, holefraction_, per : {xPer_, yPer_}] :=
If[Norm[p - Round[p, per]] < radius, holefraction, 1]

Plot3D[PeriodicHole[{x, y}, .2, .1, {.5, .4}], {x, 0, 1}, {y, 0, 1},
PlotPoints -> 50, MeshFunctions -> {#3 &},
PlotStyle -> Directive[Orange, Specularity[White, 20]]] • Round[ ] threads automatically over lists – Dr. belisarius Apr 10 '15 at 0:43

You can generate the conditions that should go inside Which on the fly.

holes[x_, y_, radius_, holefraction_] := Which @@ Flatten[{
Table[
{Norm[{xp - x, yp - y}] <= radius, holefraction},
{xp, 0, 10},
{yp, 0, 10}
],
True, 1
}];


Test:

DensityPlot[
holes[x, y, 0.3, 0.5],
{x, 0, 10}, {y, 0, 10},
PlotPoints -> 100
] myBlock = ImplicitRegion[RegionMember[Cuboid[], {x, y, z}], {x, y, z}];

ImplicitRegion[
RegionMember[
Cylinder[{{xcenter, ycenter, 1.05}, {xcenter, ycenter, 1 - depth}}, radius],
{x, y, z}], {x, y, z}];

RegionPlot3D[
RegionDifference[myBlock,
RegionUnion[
Table[myHole[x, y, .06, .3], {x, .2, .8, .2}, {y, .2, .8, .2}]]],
PlotPoints -> 100] If you want to have a single iteration variable, use Mod and Floor this way:

RegionPlot3D[
RegionDifference[myBlock,
RegionUnion[
Table[myHole[.25 (Mod[i, 3]+1), .25 (Mod[Floor[i/3], 3]+1), .06, .3],
{i, 0, 8}]]],
PlotPoints -> 100,
Boxed->False]