Message Boards Message Boards

[GIF] Step Out (Recursive triangle morph)

Recursive triangle morph

Step Out

A follow-up to Advance. In Advance I recursively defined a nested sequence of squares by having the midpoint of each edge of the previous square be a vertex of the next square. Of course, there's no reason that the vertex at the next level has to be at the midpoint: we can put it at any fixed ratio of the distance along an edge and get a whirl.

The other part of Advance was to have each midpoint move radially outward until the convex hull of the original vertices and the scaled midpoints formed a new square. As @Sander Huisman pointed out in the comments, one could do the same for any $n$-gon and get a nice periodic motion.

We could just as well form the nested collection by putting the vertices at the next level at any fraction $w$ of the way along the edges of the previous level, and we could use that same point along the edge as the point to scale up to get new $n$-gons.

In general, this does not give a periodic motion, but for certain special values of $w$ it does. When $n=3$, the values of $w$ that give periodic motion seem to be $1/2$, $1/3$, and $\frac{1}{2}(1-\frac{1}{\sqrt{3}})$. The animation above is the one you get from $w=\frac{1}{2}(1-\frac{1}{\sqrt{3}})$.

Here's the code (notice that in the code I'm using $2w$ in the definition of WeightedMidpoints):

smootherstep[x_] := 6 x^5 - 15 x^4 + 10 x^3;

WeightedMidpoints[pts_, w_] := 
 Mean[({w #, (2 - w) RotateLeft[#]} &)[pts]]

DynamicModule[
 {n = 3, w = 1 - 1/Sqrt[3], depth = 100, 
  cols = RGBColor /@ {"#537780", "#FFFCCA"}, pts, t},
 Animate[
  pts = Nest[2 WeightedMidpoints[#, w] &, 2 Sqrt[2.] CirclePoints[n],  Floor[s]];
  t = smootherstep[Mod[s, 1]];
  Graphics[
   {Table[
       {FaceForm[If[OddQ[i], cols[[1]], cols[[2]]]], Polygon[Riffle[#[[i]], (1 + t) WeightedMidpoints[#[[i]], w]]]},
       {i, 1, Length[#]}] &@NestList[WeightedMidpoints[#, w] &, pts, depth]},
   PlotRange -> .25, ImageSize -> 540],
  {s, 0, 4}]
 ]

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

POSTED BY: Moderation Team
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