Message Boards Message Boards

[GIF] Dawn (Image of square grid under cosine)

MODERATOR NOTE: a submission to computations art contest, see more: https://wolfr.am/CompArt-22


Image of square grid under cosine

Dawn

The image of a square grid in the complex plane under the map $z \mapsto \cos z$. To get motion I'm moving the grid diagonally up and to the right.

A few quirks in the code below:

  1. I want to show the way that the map is distorting area, so I've made the grid lines long thin polygons (initially rectangles with redundant vertices on the long sides) rather than lines, so that their images have non-uniform thickness.

  2. On my first attempt, the "vertical" gridlines in the final animation suffered from rendering artifacts, which I think basically boil down to bad choices of automatic triangulations (effectively the issue described in this StackExchange thread). I tried to fix this using @J. M.'s proposed solution from the StackExchange thread, but couldn't get it to work reliably, so I just did the obvious thing and triangulated manually: this is why you see the GraphicsComplex objects and the obnoxious Partition[Flatten[Riffle[Partition junk.

Anyway, here's a Manipulate version of the code (as usual, replace Manipulate with Table or ParallelTable and Export to a GIF file with "AnimationRepetitions" -> Infinity and "DisplayDurations" -> 1/50 to generate the final image):

With[{r = \[Pi], width = \[Pi]/160, m = 100, n = 40, 
  cols = RGBColor /@ {"#120136", "#035aa6", "#40bad5", "#fcbf1e"}},
 Manipulate[
  Graphics[{
    Table[
     {Blend[cols, 1 - 5/4 (y + s)/r],
      Polygon[Join @@ Transpose[
         Table[
            ReIm[Cos[#]] & /@ {x + I (y + s - width), -x + I (y + s + width)},
          {x, -r, r, 2 (r)/m}]]]},
     {y, 2 r/n, r - 2 r/n, 2 r/n}],
    Table[{Blend[cols, 1 - 5/4 (y + s)/r],
      Polygon[Join @@ Transpose[
         Table[
            ReIm[Cos[#]] & /@ {x + I (y + s - width), r - x + I (y + s + width)},
          {x, -r, 0, 2 (r)/m}]]]},
     {y, -2 r/n, 0, 2 r/n}],
    Table[
     GraphicsComplex[
      Join @@ Transpose[
        Table[
         ReIm[-Cos[#]] & /@ {x - width + s + I y, x + width + s + I (r - y)},
         {y, -width, r + width, (r + 2 width)/m}]],
      Polygon[
       Join[
        Partition[Flatten[Riffle[Partition[Range[m + 1], 2, 1],
           Reverse@Range[m + 3, 2 m + 2]]], 3],
        Partition[
         Flatten[Riffle[Partition[Range[m + 2, 2 m + 2], 2, 1],
           Reverse@Range[2, m + 1]]], 3]]],
      VertexColors -> Join[#, Reverse[#]] &[
       Table[Blend[cols, 1 - 5/4 i], {i, 0, 1, 1/m}]]],
     {x, -2 r/n, r, 2 r/n}]},
   PlotRange -> {{-\[Pi], \[Pi]}, {0, 2 \[Pi]}}, ImageSize -> 540, 
   Background -> cols[[1]]],
  {s, 0, 2 r/n}]
 ]
2 Replies

Congratulations! Your post was highlighted on the Wolfram's official social media channels. Thank you for your contribution. We are looking forward to your future posts.

POSTED BY: EDITORIAL BOARD

enter image description here -- you have earned Featured Contributor Badge enter image description here Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

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