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]
J. M.'s missing motivation
127k11 gold badges411 silver badges590 bronze badges
asked Dec 26, 2016 at 8:56
$\endgroup$
2
  • 2
    $\begingroup$ Are you sure this is not an illusion? $\endgroup$ Commented 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$ Commented 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

answered Dec 26, 2016 at 9:38
$\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$ Commented Dec 26, 2016 at 9:45
  • $\begingroup$ @Sumit you mean the second version with the transparent lines still shakes a little? $\endgroup$ Commented 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$ Commented 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

answered Dec 26, 2016 at 9:34
$\endgroup$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.