16
$\begingroup$

As you can see, the circles are shaking vertically as they approaching each other. Why is that?

The code:

g = Table[
    Graphics[{Thickness[0.01], 
             Table[{ Circle[{0 + x, 0}, r], Circle[{2 - x, 0}, r]}, {r, 0.001,1.0, 0.05}]}, 
             ImageSize -> {800, 400}], 
             {x, 0, 1, 0.02}];
SetDirectory@NotebookDirectory[]
Export["moire_pattern.gif", g]
$\endgroup$
2
  • 2
    $\begingroup$ Are you sure this is not an illusion? $\endgroup$
    – mattiav27
    Dec 26, 2016 at 9:15
  • $\begingroup$ @mattiav27 If you scroll the image on your browser so that the top of the circles touches the top of the display window, you will see clearly that the disks do wobble. Compare with Sumit 's solution where they don't. $\endgroup$
    – A.G.
    Dec 26, 2016 at 18:05

2 Answers 2

7
$\begingroup$

As @mattiav27 already commented, I too suspected an optical illusion so I added two lines to the graphic as in

g = Table[
Graphics[{Thickness[0.01], 
Table[{
Red, (*new*)
Line[{{-1, 0.95}, {3, 0.95}}], (*new*)
Line[{{-1, -0.95}, {3, - 0.95}}],(*new*)
Black,(*new*)
Circle[{0 + x, 0}, r],
Circle[{2 - x, 0}, r]}, {r, 0.001, 1.0, 0.05}]}, 
ImageSize -> {600, 300}], {x, 0, 1, 0.02}];

image

and the "wobble" is gone. It turns out though that something goes wrong with the graphic with regard to padding or image size without the lines. Try making the lines transparent via Opacity[0] and still the "wobble" is gone. I suspect adding the two Line-primitives increases padding somewhat which fixes the issue as shown in @Sumit `s answer.

g = Table[
Graphics[{Thickness[0.01], 
Table[{
Opacity[0], (*new*)
Line[{{-1, 0.95}, {3, 0.95}}], (*new*)
Line[{{-1, -0.95}, {3, - 0.95}}],(*new*)
Opacity[1], (*new*)
Black,(*new*)
Circle[{0 + x, 0}, r],
Circle[{2 - x, 0}, r]}, {r, 0.001, 1.0, 0.05}]}, 
ImageSize -> {600, 300}], {x, 0, 1, 0.02}];

image2

$\endgroup$
3
  • $\begingroup$ I think it does shake a little. If you remove the lines and use Frame->True, I think you can see it. Most probably including the lines are fixing the padding somehow (not quite sure though). $\endgroup$
    – Sumit
    Dec 26, 2016 at 9:45
  • $\begingroup$ @Sumit you mean the second version with the transparent lines still shakes a little? $\endgroup$
    – Sascha
    Dec 26, 2016 at 9:46
  • $\begingroup$ I mean, if you take the code from the question and simply add Frame you would be able to see a small wobling. It happens when you put graphics inside Manipulate. Your both answers are free from any shakyness :) $\endgroup$
    – Sumit
    Dec 26, 2016 at 9:56
15
$\begingroup$

Add ImagePadding -> 0.

g = Table[Graphics[{Thickness[0.01], 
 Table[{Circle[{0 + x, 0}, r], Circle[{2 - x, 0}, r]}, {r, 0.001, 1.0, 0.05}]},
 ImageSize -> {800, 400}, ImagePadding -> 0], {x, 0, 1, 0.02}];

SetDirectory@NotebookDirectory[] 
Export["moire_pattern.gif", g]

enter image description here

$\endgroup$

Your Answer

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

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