Message Boards Message Boards


[GIF] Square Up (Trig surface animation)

Posted 3 years ago
2 Replies
5 Total Likes

Trig surface animation

Square Up

Just an animation of the graph of $f(x,y)=\frac{6}{5} \sin^3(\theta/2) \sin(6 \theta) \sin x \sin y$ as $\theta$ ranges from $0$ to $2\pi$.

Of course, originally this was just the surface with PlotStyle->None and with an appropriately-spaced mesh (which, as @J. M. has been pointing out to me in various threads, is much faster), but there doesn't seem to be a good way to get MeshStyle to color a single mesh line in different colors (something like ColorFunctions), so I had to build my own mesh with lines and color it with VertexColors.

Also, I'm experimenting with some different code formatting, so let me know if you have any strong opinions:

  n = 20,
  a = 1.2,
  k = 6,
  cols = RGBColor /@ {"#28C7FA", "#FF304F", "#002651"}
         Line[#[[i]], VertexColors -> (Blend[cols[[;; -2]], (# + a)/(2 a)] & /@ #[[i, ;; , 3]])],
         {i, Length[#]}] & /@ {#, Transpose[#]}
      &[Table[{2 π (x - 1)/n, 2 π (y - 1)/n, 
       a*Haversine[θ]^(3/2) Sin[k θ] Sin[2 π (x - 1)/n] Sin[2 π (y - 1)/n]},
      {x, 1, n + 1}, {y, 1, n + 1}]
   Boxed -> False,
   PlotRange -> {{-.5, 2 π + .5}, {-.5, 2 π + .5}, {-2.5, 2.5}},
   ImageSize -> 540,
   ViewPoint -> {2, 0, 1},
   SphericalRegion -> True,
   Background -> cols[[-1]]],
  {θ, 0, 2 π}]
2 Replies
Posted 3 years ago

Yes, it's a known weakness of Mesh that it doesn't take an associated ColorFunction, which is a pity for makers of fine artwork. ;)

A physically realistic variant would be to look at the surfaces corresponding to the so-called "Chladni plates" (see e.g. this Demonstration).


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!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract