Message Boards Message Boards

GROUPS:

[GIF] Rolling (Circles rolling inside a circle)

Posted 23 days ago
346 Views
|
1 Reply
|
4 Total Likes
|

Circles rolling inside a circle

This one is pretty simple: take two circles of radius 1/2 rolling inside a unit circle and track a point on each circle's perimeter. The points turn out to follow straight lines, and the challenge is to make this seem both surprising and obvious (and also to fit it all under 3 MB). Not sure if I succeeded, but that was the idea, anyway.

Here's the code:

smoothstep[x_] := 3 x^2 - 2 x^3;

With[{a = 1, b = 1/2, cols = RGBColor /@ {"#303841", "#f3f6f6"}},
 Manipulate[
  Graphics[{
    Thickness[.0075], cols[[1]],
    Opacity[
     Which[t < 8 π, 1, 8 π <= t < 12 π, 
      1 - smoothstep[(t - 8 π)/(4 π)], 
      12 π <= t < 14 π, 0, 14 π <= t <= 18 π, 
      smoothstep[(t - 14 π)/(4 π)]]],
    Table[
     Circle[(a - b) {Cos[t + π i], Sin[t + π i]}, b], {i, 0, 1}],
    Opacity[
     Which[t < 6 π, 0, 6 π <= t < 8 π, 
      smoothstep[(t - 6 π)/(2 π)], 8 π <= t < 14 π, 1,
       14 π <= t <= 18 π, 
      1 - smoothstep[(t - 14 π)/(4 π)]]],
    Thickness[.01],
    Line[
     Table[(a - b) {Cos[s], Sin[s]} + b {Cos[-(a - b)/b s], Sin[-(a - b)/b s]}, {s, t - 3 π/4, t, π/100}],
     VertexColors -> 
      Table[Blend[{Directive[cols[[2]], Opacity[0]], cols[[1]]}, s], {s, 0, 1, 1/75}]],
    Line[
     Table[(a - b) {Cos[s + π], Sin[s + π]} + b {Cos[-(a - b)/b s], Sin[-(a - b)/b s]}, {s, t - 3 π/4, t, π/100}],
     VertexColors -> 
      Table[Blend[{Directive[cols[[2]], Opacity[0]], cols[[1]]}, s], {s, 0, 1, 1/75}]],
    Opacity[1], cols[[1]], Thickness[.0075], Circle[], 
    PointSize[.03],
    Table[
     Point[(a - b) {Cos[t + i π], Sin[t + i π]} + b {Cos[-(a - b)/b t], Sin[-(a - b)/b t]}], {i, 0, 1}]},
   Background -> cols[[-1]], PlotRange -> Sqrt[2], ImageSize -> 540],
  {t, 0, 18 π}]
 ]

enter image description here - Congratulations! This post is now a Staff Pick as distinguished by a badge on your profile! Thank you, keep it coming, and consider contributing your work to the The Notebook Archive!

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