Message Boards Message Boards

GROUPS:

[GIF] Moving bars illusion

Posted 5 years ago
12159 Views
|
6 Replies
|
18 Total Likes
|

enter image description here

These bars are moving at a constant speed together, but it looks as if they move to the right in an alternating fashionÂ…

Code:

size={sizex,sizey}={600,400};
n=16;
bars=sizex Subdivide[-1/2,1/2,2n-1];
width=N[bars[[2]]-bars[[1]]];
bars=Rectangle[{#1,-sizey/2},{#2,sizey/2}]&@@@Partition[bars,2];
cols={Lighter[Yellow,1/5],Darker[Blue,1/5]};
heights=N[sizey Subdivide[-1/2,1/2,Length[cols]+1][[2;;-2]]];
ClearAll[CreateScene]
CreateScene[\[Alpha]_]:=Module[{recs},
    recs=MapThread[{#1,Rectangle[{\[Alpha] sizex-2 width,#2-width/2},{\[Alpha] sizex+2 width,#2+width/2}]}&,{cols,heights}];
    Rasterize[Graphics[{bars,recs},PlotRange->({{-1,1},{-1,1}}size/2),PlotRangePadding->0],"Image",RasterSize->size,ImageSize->size]
]

Manipulate[CreateScene[a], {a, -0.6, 0.6}]

enjoy!

POSTED BY: Sander Huisman
6 Replies
Posted 5 years ago

Nice. If these were cars on a US freeway, one of them would be frantically changing lanes back and forth in an attempt to always travel in the fastest lane, which would of course bring an end to the continuous progress.

POSTED BY: David Keith

Hadn't thought about that analogy! great!

POSTED BY: Sander Huisman
Posted 5 years ago

Maybe this explains my wife's exclamation that the other driver "came out of nowhere." Now that I think of it, I think the other driver was in a yellow car. Hmm...

POSTED BY: Mark Greenberg
Posted 5 years ago

I am impressed. Perhaps a suggestion, put another screen below the first one without the black bars so we can see the rectangles move together at the same speed.

POSTED BY: BJ Miller

enter image description here -- you have earned Featured Contributor Badge enter image description here

Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you, keep it coming, and consider contributing to the The Notebook Archive!

POSTED BY: Moderation Team

It would seem to me that bw bars produce an effect similar to a strobe light.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract