In order to start the animation move the mouse into the picture. Pressing the mouse button and dragging the mouse will rotate the whole system. Pressing the meta key (alternate on most systems) together with the mouse button and dragging horizontally will switch through the frames of the animation. (Dragging vertically while pressing the meta key will hide polygons or show them again.) This example is a strongly simplified version of the Mathematica 3.0 demo "Interlocking tori" by W. Gosper. (See "Getting Started/Demos -> Graphics Gallery -> Animations -> Interlocking Tori" in the online help of Mathematica 3.0.) |
First a standard package has to be loaded:
<<Graphics`Shapes`;
The following Mathematica commands are needed to produce this animation:
torusKnot[ro_,ri_,alpha_,i_,j_]:= ro{- Cos[alpha*i],Sin[alpha*i],0}+ ri (Cos[alpha*j]/Cos[alpha/2]*{Cos[alpha*i],-Sin[alpha*i],0}+ Sin[alpha*j]*{0,0,1}); torus[ri_,ro_,n_]:= Module[{alpha=N[2Pi/n]}, TranslateShape[ Graphics3D[ Table[Polygon[{torusKnot[ro,ri,alpha,i,j], torusKnot[ro,ri,alpha,i+1,j],torusKnot[ro,ri,alpha,i+1,j+1], torusKnot[ro,ri,alpha,i,j+1]}],{i,1/2,n},{j,1/2,n-1}]],{ ro Cos[alpha/2]-ri Cos[alpha/2],0,0}]]; interlockingTori[ri_,ro_,n_]:= Module[{t1,t2,ri2,ro2,alpha=N[2Pi/n]},ri2=(ro-ri);ro2=ri +ri2; t1=torus[ri,ro,n]; t2=RotateShape[AffineShape[torus[ri2,ro2,n],{-1,1,1}],0,Pi/2,0]; Graphics3D[Flatten[{t1[[1]],t2[[1]]}]]]; animatedTori[n_,t_]:= Module[{gl}, gl=Table[RotateShape[interlockingTori[i,10,n], If[EvenQ[n],0,(2.Pi/n)/2/t*i],-Pi/2/t*i,0],{i,0,t-1}]; ShowAnimation[gl,SphericalRegion->True,Boxed->False, PlotRange->{{-28,28},{-28,28},{-28,28}}]]; animatedToriInputForm[n_,t_]:= Module[{gl}, gl=Table[RotateShape[interlockingTori[i,10,n], If[EvenQ[n],0,(2.Pi/n)/2/t*i],-Pi/2/t*i,0],{i,0,t-1}]; HoldForm[ShowAnimation][NumberForm[InputForm[N[gl]],4], NumberForm[ InputForm[ N[{SphericalRegion->True,Boxed->False, PlotRange->{{-28,28},{-28,28},{-28,28}}, LightSources->{{{1., 1., 1.}, RGBColor[1, 0.5, 0.5]},{{-1,-1,-1},RGBColor[0.5,0.5,1]}}, AnimationDirection->Forward, AnimationDisplayTime->0.06}]],4]]]
With these definitions animatedTori[5, 9] will show this example within Mathematica (with the standard light sources) and animatedToriInputForm[5, 9] will produce an InputForm appropriate for LiveGraphics3D.