Message Boards Message Boards

[GIF] Compression (Deforming the hex lattice)

GROUPS:

Deforming the hex lattice

Compression

I started with the triangular grid I built for Release and applied VoronoiMesh to get a hexagonal lattice. Moving the points produces a nice animation, but unfortunately I couldn't figure out how to get variable colors on the edges of the mesh in a sensible way (I know I can color by index, but I couldn't get the numbering of the cells in the mesh to be consistent enough to be useful when I started moving things around).

Here's the code for the monochromatic VoronoiMesh version of this:

DynamicModule[{cols, dots},
 cols = {GrayLevel[.2], GrayLevel[.98]};
 Manipulate[
  dots = Flatten[
    Table[Haversine[
        Clip[t - π (Sqrt[3]/2 y + 3/2 x + 4 + 
              4 Sqrt[3])/(4 Sqrt[21]), {0, π}]] 2 Sqrt[
        3] {Sin[π/3], Cos[π/3]} + {3 x/2, 
       Sqrt[3] y + (1 - (-1)^x ) Sqrt[3]/4}, {x, -6, 5}, {y, -5, 5}], 
    1];
  VoronoiMesh[dots, PlotRange -> 6, ImageSize -> 540, 
    PlotTheme -> "Lines", 
    MeshCellStyle -> {1 -> {Thickness[.004], cols[[1]]}, {2, All} -> 
       cols[[-1]]}], {t, 0, 2 π}]
 ]

(If you want to export the above to a GIF, it's a good idea to Rasterize the VoronoiMesh.)

Given my inability to get the colors I wanted, I ended up making a loose approximation to the Voronoi mesh by hand. It's definitely not exactly the same, but has some of the same basic characteristics. But it's certainly a dirty hack, and the code is correspondingly unpleasant:

DynamicModule[{cols, θ, points, b},
 cols = RGBColor /@ {"#FF7070", "#4AC6B7", "#4F5E7F"};
 θ[i_, j_, t_] := 4/5 (t - π (i - j + 8)/20);
 b[i_, j_, t_] = Haversine[Clip[2 θ[i, j, t], {0, 2 π}]];
 Manipulate[
  points = Table[
    {Blend[cols[[;; 2]], b[i, j, t]], 
     Haversine[Clip[θ[i, j, t], {0, π}]] 2 Sqrt[
        3] {Cos[π/6], 
        Sin[π/6]} + {(-1)^i/
          8 ((1 - b[i, j, t]/1.8) - (-1)^i * 5 + (-1)^i *6 i) + 
        1, (-1)^i/8 Sqrt[
          3] (-(1 - b[i, j, t]/1.8) - (-1)^i*3 + (-1)^i * 2 i) - 
        Sqrt[3] j}}, {j, -6, 5}, {i, -14, 10}];
  Graphics[{Thickness[.006], CapForm["Round"], 
    Table[Line[points[[i, ;; , 2]], 
      VertexColors -> points[[i, ;; , 1]]], {i, 1, Length[points]}], 
    Table[Line[{points[[j, 2 i + 1, 2]], points[[j + 1, 2 i + 2, 2]]},
       VertexColors -> {points[[j, 2 i + 1, 1]], 
        points[[j + 1, 2 i + 2, 1]]}], {j, 1, 11}, {i, 1, 
      Length[points] - 1}]}, PlotRange -> 6, ImageSize -> 540, 
   Background -> cols[[-1]]], {t, 0., 2 π}]
 ]
POSTED BY: Clayton Shonkwiler
Answer
11 months ago

Another hex lattice deformation

Circuit

Following a suggestion of Admiral Potato, here's a version with compression along each of the three possible axes.

POSTED BY: Clayton Shonkwiler
Answer
10 months ago

enter image description here - 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!

POSTED BY: Moderation Team
Answer
10 months ago

Group Abstract Group Abstract