Message Boards Message Boards

[GIF] Hidden Depths (Reflections in a Disk)

Reflections in a Disk

Hidden Depths

This is a follow-up to Emergent Order; in both, rays extend from a common starting point, reflecting off the boundary of the disk whenever they meet it. The only differences are the colors and the starting points. In general, of course, one can cause any regular polygon to be repeatedly covered by choosing an appropriate starting point.

The code uses NDSolve along with WhenEvent to handle the reflections; as written it's not very efficient, but here's the code I used to generate the GIF:

sol = With[
   {α = Pi/10, n = 40},
   Table[
    NDSolve[{x'[t] == a[t], y'[t] == b[t], x[0] == 0, 
      y[0] == Sin[α], a[0] == Cos[θ], 
      b[0] == Sin[θ],
      WhenEvent[
       x[t]^2 + y[t]^2 == 1, 
        {a[t], b[t]} -> -(2*({a[t], b[t]}.{-x[t], -y[t]}) {-x[t], -y[t]} - {a[t], b[t]})]
      },
     {x, y}, {t, 0, 100}, DiscreteVariables -> {a, b}],
    {θ, 0, 2 Pi - 2 Pi/n, 2 Pi/n}]];

star = With[
   {cols = RGBColor /@ {"#F5E495", "#F7825D", "#00032D"}},
   ParallelTable[
    Show[
     ParametricPlot[{x[t], y[t]} /. sol,
        {t, 0, If[s <= 1, s^2, s^(3/2)]}, 
      Frame -> True, FrameTicks -> None, 
      PlotRange -> 1.2, Background -> cols[[-1]], 
      ImageSize -> {540, 540}, Axes -> False, 
      PlotStyle -> Directive[Thickness[.0005], cols[[1]]]],
     Graphics[{Darker[cols[[2]], .45], Thickness[.004], Circle[]}]],
    {s, .0001, 8.0001, .08}]
   ];

Export[NotebookDirectory[] <> "star.gif", star, "DisplayDurations" -> Append[Prepend[ConstantArray[1/12, 99], 1], 3]]
3 Replies

A slightly different version with a bit more reflections (twice longer time in the solution) and Opacity[.5] added to reflected lines.

enter image description here

POSTED BY: Vitaliy Kaurov

Interesting that I didn't use opacity in the original. I have some vague recollection that there was a reason, but I can't remember now.

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!

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