Rotating Square Illusion

Author

Eric W. Weisstein
September 1, 2007

This notebook downloaded from http://mathworld.wolfram.com/notebooks/RecreationalMath/RotatingSquareIllusion.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/RotatingSquareIllusion.html.

©2007 Wolfram Research, Inc. except for portions noted otherwise

Graphic

V5.2

<<Graphics`InequalityGraphics`

Timing[
g=Show[Table[InequalityPlot[r<(x^4+y^4)^(1/4)<r+.5,{x},{y},DisplayFunction->Identity,
Fills->GrayLevel[0],
Curves->None,
PlotPoints->50,
Axes->False],{r,0,5}],
DisplayFunction->$DisplayFunction
]
]

Animation

rot[α_]:={{Cos[α],Sin[α]},{-Sin[α],Cos[α]}}

Timing[
movie=Show[#,PlotRange->7{{-1,1},{-1,1}}]&/@Table[g/.{
Line[l_List]:>Line[rot[α].#&/@l],
Polygon[l_List]:>Polygon[rot[α].#&/@l]
},{α,0,Pi/2-.01,Pi/2/20.}]
]

<<Utilities`GIF`

Export[gifs<>"rotsq.gif",movie]//Timing

V6

RotationMatrix[θ].{x,y}

c1=ContourPlot[(x^4+y^4)^(1/4),{x,-1,1},{y,-1,1},ContourStyle->None,Contours->Range[0,1,1/10],Frame->False,ContourShading->{White,Black},RegionFunction->Function[{x,y},(x^4+y^4)^(1/4)<.99]][[1]];

Graphics[c1]

c1=ContourPlot[(x^4+y^4)^(1/4),{x,-1,1},{y,-1,1},ContourStyle->None,Contours->Range[0,1,1/10],PlotPoints->2,Frame->False,ContourShading->{White,Black},RegionFunction->Function[{x,y},(x^4+y^4)^(1/4)<.99]][[1]];

Animate[Graphics[Rotate[c1,θ],PlotRange->1.2],{θ,0,π/2},DisplayAllSteps->True]

1

c2=RegionPlot[FractionalPart[(x^4+y^4)^(1/4)]<1/2,{x,-1,1},{y,-1,1},ColorFunction->(Black&),PlotPoints->30,Frame->False][[1]];

Animate[Graphics[Rotate[c2,θ],PlotRange->1.2],{θ,0,π/2},DisplayAllSteps->True]