Message Boards Message Boards

[GIF] RGB (Spinning triangles)

Spinning triangles

RGB

Not too much in the way of deep math in this one. It's more in the style of something like Coalesce or Snap to Grid, though the very first version of this predates both and eventually morphed into Cross Purposes.

I guess the basic idea is pretty self-explanatory and mostly encoded in the function f, which causes little triangles to preferentially spin according to their magnitudes in each of the three axis directions of the big triangle. The mess inside Blend is trying to color according to which of those three preferential directions is currently active, though I admit the resulting behavior is kind of complicated and it's not 100% clear I got it completely right.

Here's the code:

smootheststep[t_] := -20 t^7 + 70 t^6 - 84 t^5 + 35 t^4;

DynamicModule[{n = 8, f, 
  cols = {White, Red, Blue, Green, GrayLevel[.05]}},
 f[x_, y_, t_] := 
  smootheststep[Clip[t - (n - y)/(2 n), {0, 1}]] + 
   smootheststep[Clip[t - (3 n - {x, y}.{-2, -1})/(4 n), {0, 1}]] + 
   smootheststep[Clip[t - (3 n + {x, y}.{-2, 1})/(4 n), {0, 1}]];
 Manipulate[
  Graphics[{
    Table[
     {Blend[{cols[[1]],
        Blend[cols[[2 ;; -2]], 
          {Haversine[2 π smootheststep[Clip[t - (n - y)/(2 n), {0, 1}]]], 
          Haversine[2 π smootheststep[Clip[t - (3 n - {x, y}.{-2, -1})/(4 n), {0, 1}]]], 
          Haversine[2 π smootheststep[ Clip[t - (3 n + {x, y}.{-2, 1})/(4 n), {0, 1}]]]}]},
       Haversine[2 π f[x, y, t]]],
      Polygon[
       Table[
        {Cos[θ + 2 π/3 f[x, y, t]] + Sqrt[3] x, Sin[θ + 2 π/3 f[x, y, t]] + 3/2 y},
        {θ, π/2, 2 π, 2 π/3}]]},
     {y, -n, n}, {x, -n + (y + n)/2, n - (y + n)/2}]},
   PlotRange -> Sqrt[6] n, Background -> cols[[-1]], ImageSize -> 540],
  {t, 0, 2}]
 ]

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