Skip to content

Instantly share code, notes, and snippets.

@taroyabuki
Last active August 28, 2019 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taroyabuki/98d5e34ea996382adb9d to your computer and use it in GitHub Desktop.
Save taroyabuki/98d5e34ea996382adb9d to your computer and use it in GitHub Desktop.
roll = 10;
surface[s_, t_] :=
RotationMatrix[s, {0, 0, 1}].{3 + t Cos[t]/(roll Pi), 0, t Sin[t]/(roll Pi)}
donut[t_] :=
ParametricPlot3D[surface[s, u], {s, 0, 2 Pi}, {u, 0, t},
Axes -> False, Boxed -> False, Mesh -> None, PlotPoints -> 40]
bugs[t_, n_] :=
Graphics3D[{PointSize[0.03],
Point[Table[surface[s, t], {s, 0, 2 Pi (1 - 1/n), 2 Pi/n}]]},
Boxed -> False]
f = 100;
frames = ParallelTable[
Show[donut[t], bugs[t, 50],
PlotRange -> {{-4, 4}, {-4, 4}, {-1, 1}}], {t, 0.001, roll Pi, roll Pi/f}];
ListAnimate[Reverse[frames]]
Export["2019-08-14-donut.gif", Reverse[frames],
AnimationRepetitions -> Infinity, "DisplayDurations" -> 1/10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment