Skip to content

Instantly share code, notes, and snippets.

@BrianWeinstein
Last active August 29, 2015 14:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianWeinstein/cf875cdf57c7c6a0c282 to your computer and use it in GitHub Desktop.
Save BrianWeinstein/cf875cdf57c7c6a0c282 to your computer and use it in GitHub Desktop.
circ = 1; rad = circ/(2 \[Pi]); nRunners = 5;
rList[t_] := {1 t, 2 t, 4 t, 8 t, 9.6 t, 21 t, 31 t, 33 t}[[1 ;; nRunners]]
dist[d\[Theta]_, circ_] :=
N[circ/2 (TriangleWave[(d\[Theta] - \[Pi]/2)/(2 \[Pi])] + 1)/2]
minDist[runnerList_, circ_] :=
Table[
runner = runnerList[[i]];
other = DeleteCases[runnerList, runner];
Min[dist[Abs[runner - other], circ]],
{i, 1, nRunners}
]
colorList = Table[ColorData[97, "ColorList"][[i]], {i, 1, 10}];
colorListLighter = Table[Lighter[ColorData[97, "ColorList"][[i]], 0.7], {i, 1, 10}];
Manipulate[
{Graphics[
{
White, EdgeForm[Black],
Disk[{0, 0}, rad + 0.005 (nRunners + 3)],
Disk[{0, 0}, rad - 0.005*3],
Table[
{
If[(minDist[rList[tmax], circ][[i]]) >= 1/nRunners,
colorList[[i]] = colorListLighter[[i]],
White
],
Thickness[0.01],
Circle[{0, 0},
rad + 0.005 i, {rList[tmax][[i]] - (2 \[Pi])/nRunners,
rList[tmax][[i]] + (2 \[Pi])/nRunners}]
}
, {i, 1, nRunners}
],
Table[
{
If[(minDist[rList[tmax], circ][[i]]) >= 1/nRunners,
colorList[[i]] = colorListLighter[[i]],
colorList[[i]]
], PointSize[0.05],
Point[(rad + 0.005 i) {Cos[rList[tmax][[i]]],
Sin[rList[tmax][[i]]]}]
}
, {i, 1, nRunners}
],
{Black, Text[Style[ToString[nRunners], 14, Italic], {0, 0}]}
},
PlotRange -> rad + 0.005 (nRunners + 3) + 0.01
]}[[1]],
{tmax, 0.00001, 3, .00001}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment