# Construction of Moiré interference pattern

I would like to produce an Moiré interference pattern with the following code:

g[n_, center_] :=
Graphics[{Table[{If[EvenQ[i], Black, White], Opacity[0.5],
Disk[center, Rescale[i, {0, n}, {1, 0}]]}, {i, 0, n}]}];

Manipulate[
Show[g[n, {0, 0}], g[n, {1, 0}]], {n, 2, 150, 1}]


A result for n=12 is the following: How can I apply Opacity correctly?

• I am sorry, do you know what means an interference pattern? I think you mean Moire pattern, don't you? The interference pattern of two circular waves of the same frequency gives a static pattern consisting in hyperbolas whose foci are the center of the circular waves, roughly speaking... – José Antonio Díaz Navas Nov 5 '17 at 17:49
• @José Antonio Díaz Navas: In en.wikipedia.org/wiki/Moiré_pattern you find the word interference even it has not a physical meaning: "In mathematics, physics, and art, a moiré pattern (/mwɑːrˈeɪ/; French: [mwaʁe]) or moiré fringes are large-scale interference patterns that can be produced when an opaque ruled pattern with transparent gaps is overlaid on another similar pattern. For the moiré interference pattern to appear, the two patterns must not be completely identical in that they must be displaced, rotated, etc., or have different but similar pitch." ... – mrz Nov 5 '17 at 18:16
• Moire patterns are produced by aliasing problems in resolution when the spatial frequency of the details are not properly sampled, and are reproduced having lower spatial frequencies. This issue is mostly associated to the detector that registers the details, as it samples at discrete points. Nothing to do with how the patterns "interfere". That is why I do not like the use that in some context is given to "interference", ;)) – José Antonio Díaz Navas Nov 5 '17 at 19:02

One way to see the interference patterns is to make the white parts transparent and the black parts opaque. A simple way to do this is to use Circle instead of Disk:

g[n_, cen_] := Graphics[{Table[Circle[cen, Rescale[i,{0, n},{1, 0}]], {i, 0, n}]}];

Manipulate[Show[g[n, {0, 0}], g[n, {1, 0}]], {n, 1, 100}] You can also see some very nice Moire effects by moving the circles around:

Manipulate[Show[g[n, {0, 0}], g[n, x]], {n, 1, 100}, {x, {-1, -1}, {1, 1}}] • Good idea to replace Disk by Circle ... it makes everything easier – mrz Nov 5 '17 at 19:46

The reason why the interference pattern fades as you get closer to one of the centers is that the Disk's from a single 'source' are overlapping. The simple fix to this is to switch from using Disk to Annulus. Defining a function to wrap the color and opacity,

colorOpacity[n_] := Opacity[.5, If[EvenQ[n], White, Black]]


and then rewriting your g to leverage this and use Annulus (and getting rid of using 'Table'),

g[n_, center_] := Graphics[{{colorOpacity[n], Disk[center, 1/n]},
{colorOpacity[#], Annulus[center, 1 - {#, # - 1}/n]} & /@ Range[n - 1]}]


This yields something slightly better,

n = 12; Show[g[n, {0, 0}], g[n, {1, 0}]] Notice however that regions where it is Black from the left center and White from the right center are a different color than the reverse. This is because Opacity makes things opaque and doesn't take some sort of average.

To address this we can separate the White rings from the Black rings and place the White rings on the highest layers,

minG[n_, c_] := With[{colorDir = Opacity[0.5, White]},
Graphics[{{colorDir, Disk[c, 1/n]},
{colorDir, Annulus[c, 1 - {#, # - 1}/n]} & /@ (2 Range[(n - 1)/2])}]];
maxG[n_, c_] := Graphics[{{Opacity[0.5, Black],
Annulus[c, 1 - {#, # - 1}/n]} & /@ (2 Range[(n + 1)/2] - 1)}];


This yields something better yet,

n = 12; c1 = {0, 0}; c2 = {1, 0};
Show[maxG[n, c1], maxG[n, c2], minG[n, c1], minG[n, c2]] However things still aren't perfect; we see that the minimum from the constructive interference from two White rings are the same color as that of a single White ring. This is tricker to solve if we stay with gray scale images. The only way I can think of doing this is to rasterize and do some image processing.

Instead if we simply change the colors to Blue and Red instead of Black and White in the definitions of minG and maxG we can get a pretty good compromise. • Thanks a lot for the very detailed solution and explanation. – mrz Nov 5 '17 at 19:45
• @mrz Hopefully it was still of some use; I made the solution before I saw you clarified that you were looking for Moiré patterns. – qbit Nov 5 '17 at 23:01
• I think this is very interesting how you solved the interference problem. I was not precise about physical interference or Moiré "interference", please excuse me. – mrz Nov 6 '17 at 8:43