Message Boards Message Boards

[GIF] Inertia (Distorted grid)

Distorted grid

Inertia

Back to the broken grids.

The code is kind of unpleasant because I was having trouble adapting my initial monochromatic code to allow the dots and lines to have variable colors. Presumably there's a cleaner way of doing this, but I just bolted the colors on rather than re-writing.

DynamicModule[{cols, grid},
 cols = RGBColor /@ {"#B463A6", "#00C3FF", "#3B475E"};
 Manipulate[
  grid = Table[{Blend[cols[[;; -2]], 
        Haversine[Clip[2 #, {0, 2 ?}]]], 
       RotationMatrix[?/2 Haversine[Clip[ #, {0, ?}]]].{x, 
         y}} &[t - ? Norm[{x, y}]/Sqrt[50]], {x, -8, 8}, {y, -8, 8}];
  Graphics[{Table[{grid[[i + 9, j + 9, 1]], 
      Disk[grid[[i + 9, j + 9, 2]], .1]}, {i, -8, 8}, {j, -8, 8}], 
    Thickness[.005], 
    Line[#[[;; , ;; , 2]], VertexColors -> #[[;; , ;; , 1]]] &[
     Table[grid[[i + 9]], {i, -8, 8}]], 
    Line[#[[;; , ;; , 2]], VertexColors -> #[[;; , ;; , 1]]] &[
     Table[grid[[;; , j + 9]], {j, -8, 8}]]}, PlotRange -> 5, 
   ImageSize -> 540, Background -> cols[[-1]]],
  {t, 0, 2 ?}]
 ]
2 Replies
Posted 9 years ago

GraphicsComplex[] helps a fair bit in simplifying the code given below. The only snag is that altho GraphicsComplex[] takes a VertexColors setting, Disk[] is unaffected by it, which necessitates having to keep two copies of the colors:

With[{n = 5},
     Manipulate[Graphics[With[{cl = Flatten[Table[Blend[{RGBColor["#B463A6"], RGBColor["#00C3FF"]}, 
                                                        Haversine[Clip[2 (t - ? Norm[{x, y}]/Sqrt[50]), {0, 2 ?}]]],
                                                  {x, -n - 2, n + 2}, {y, -n - 2, n + 2}]]},
                              GraphicsComplex[Flatten[
                              Table[RotationMatrix[? Haversine[Clip[t - ? Norm[{x, y}]/Sqrt[50], {0, ?}]]/2].{x, y},
                                   {x, -n - 2, n + 2}, {y, -n - 2, n + 2}], 1],
                              {Thickness[0.005], Line[(# ~Join~ Transpose[#]) &[Partition[Range[(2 n + 5)^2], 2 n + 5]],
                                                      VertexColors -> Automatic],
                                Riffle[cl, Table[Disk[k, 0.1], {k, (2 n + 5)^2}]]}, VertexColors -> cl]], 
                            Background -> RGBColor["#3B475E"], ImageSize -> 540, PlotRange -> n], {t, 0, 2 ?}]]
POSTED BY: J. M.

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: EDITORIAL BOARD
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