Message Boards Message Boards

GROUPS:

[GIF] Come Together (Spinning hexagons)

Posted 1 year ago
2762 Views
|
1 Reply
|
9 Total Likes
|

Spinning hexagons

Come Together

An offshoot of another project which may become a thing some day. The basic idea is that a hexagon is just a truncated triangle, and so by adjusting how much you truncate you can morph smoothly between the two. Plus some spinning.

Here's the code:

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

NgonToNOver2Gon[n_, r_, center_, θ_, t_] := 
  DeleteDuplicates[Table[center + ReIm[r Exp[I (θ + 2 π /n (i + (-1)^i *t/2))]], {i, 0, n - 1}]];

DynamicModule[{t},
 Manipulate[
  t = smootheststep[1 - Abs[1 - s]];
  Graphics[{CapForm["Round"], FaceForm[None], 
    EdgeForm[Directive[JoinForm["Round"], Thickness[.008]]], 
    Table[{EdgeForm[Blend[{ColorData["BrightBands"][i/5], White}, t]],
       Polygon[
       NgonToNOver2Gon[6,1 - t/2, (2 - 3/2 t) ReIm[Exp[I*2 π/6 (i + 6 (2 smootheststep[Mod[s/2 + 1/2, 1]] - 1))]], 
         π/6 (1 + 2 i + 4 smootheststep[Mod[s, 1]] + 12 (2 smootherstep[Mod[s/2 + 1/2, 1]] - 1)), t]]},
     {i, 0, 5}]},
   PlotRange -> 4, ImageSize -> 540, Background -> GrayLevel[.15]],
  {s, 0, 2}]
 ]

enter image description here - Congratulations! This post is now a Staff Pick! Thank you for your wonderful contributions. Please, keep them coming!

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