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]
-
2$\begingroup$ Are you sure this is not an illusion? $\endgroup$mattiav27– mattiav272016年12月26日 09:15:12 +00:00Commented 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.– A.G.2016年12月26日 18:05:01 +00:00Commented Dec 26, 2016 at 18:05
2 Answers 2
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}];
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}];
-
$\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– Sumit2016年12月26日 09:45:56 +00:00Commented Dec 26, 2016 at 9:45 -
$\begingroup$ @Sumit you mean the second version with the transparent lines still shakes a little? $\endgroup$Sascha– Sascha2016年12月26日 09:46:59 +00:00Commented 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– Sumit2016年12月26日 09:56:28 +00:00Commented Dec 26, 2016 at 9:56
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]