10
|
11104 Views
|
4 Replies
|
14 Total Likes
View groups...
Share
GROUPS:

# [GIF] Waves of hexagonal columns

Posted 8 years ago
 I saw a similar animation and I had to recreate it! The code is quite easy: ClearAll[HexColumn,CellDistance,MakeFigure] hx={{1,1/2},{0,Sqrt[3]/2}}; CellDistance[p1_,p2_]:=Module[{dx,dy}, {dx,dy}=p1-p2; If[Sign[dx]==Sign[dy],Abs[dx+dy],Max[Abs[dx],Abs[dy]]] ] HexColumn[p:{x_,y_},l_]:=Module[{cap,sides}, cap=CirclePoints[p,{1/Sqrt[3],\[Pi]/2},6]; cap={Append[l/2]/@cap,Append[-l/2]/@cap}; sides=Partition[#,2,1,1]&/@cap; sides[[2]]=Reverse/@sides[[2]]; sides=Join@@@Transpose[sides]; {Polygon[cap],Polygon[sides]} ] MakeFigure[t_]:=Module[{pts,heights}, pts=N@Tuples[Range[-25,25],2]; pts=Select[pts,CellDistance[{0,0},#]<12&]; pts=hx.#&/@pts; heights=12+3.5Sin[0.9Norm[#]-t]&/@pts; Graphics3D[{EdgeForm[],MapThread[HexColumn,{pts,heights}]},Boxed->False,ViewPoint->{0, -2,1.5}, Lighting->{{"Directional",Darker[,0.1],ImageScaled[{0,2,2}]},{"Directional",Darker[,0.1],ImageScaled[{-2,-2,0}]},{"Directional",Darker[,-0.1],ImageScaled[{2,-2,0}]}}, ImageSize->{400,400}, PlotRange->{{-12,12},{-12,12},{-9,9}}, Background->White ] ] SetDirectory[NotebookDirectory[]]; imgs=Table[Rasterize[MakeFigure[\[Tau]],"Image",RasterSize->400],{\[Tau],Subdivide[0,2\[Pi],45]//Most}]; Export["out.gif",imgs,"DisplayDurations"->1/40.0] 
4 Replies
Sort By:
Posted 8 years ago
 For those that are interested, the original is by Dave Whyte.
Posted 8 years ago
 I'm not sure how you found it! But, yes! That's the one! thanks!
Posted 8 years ago
 I follow him on Tumblr and Twitter, so I remembered it from when he posted it a month or so ago.
Posted 8 years ago
 - another post of yours has been selected for the Staff Picks group, congratulations !We are happy to see you at the top of the "Featured Contributor" board. Thank you for your wonderful contributions, and please keep them coming!