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}]}];

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

A result for n=12 is the following:

enter image description here

How can I apply Opacity correctly?

  • $\begingroup$ 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... $\endgroup$ Commented Nov 5, 2017 at 17:49
  • $\begingroup$ @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[1] 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." ... $\endgroup$
    – mrz
    Commented Nov 5, 2017 at 18:16
  • 1
    $\begingroup$ 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", ;)) $\endgroup$ Commented Nov 5, 2017 at 19:02

2 Answers 2


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}]

enter image description here

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}}]

enter image description here

  • $\begingroup$ Good idea to replace Disk by Circle ... it makes everything easier $\endgroup$
    – mrz
    Commented Nov 5, 2017 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}]]

Interference with <code>n=12</code> and <code>Annulus</code>

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]]

Better interference with <code>n=12</code> and <code>Annulus</code>

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.

Better interference with colors and <code>n=12</code> and <code>Annulus</code>

  • $\begingroup$ Thanks a lot for the very detailed solution and explanation. $\endgroup$
    – mrz
    Commented Nov 5, 2017 at 19:45
  • $\begingroup$ @mrz Hopefully it was still of some use; I made the solution before I saw you clarified that you were looking for Moiré patterns. $\endgroup$
    – qbit
    Commented Nov 5, 2017 at 23:01
  • $\begingroup$ 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. $\endgroup$
    – mrz
    Commented Nov 6, 2017 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.