How can I draw the Olympic rings with Mathematica?
A rather crude way of accomplishing this is just to draw multiple shapes layered such that the rings interlock.
ringSegment[mid_, deg_, color_] := {
Thickness[0.05],CapForm["Butt"], White, Circle[mid, 1, deg], Thickness[0.03],
RGBColor @@ (color/255), Circle[mid, 1, deg + {-0.1, 0.1}]}
olblue = {0, 129, 188};
olyellow = {255, 177, 49};
olBlack = {35, 34, 35};
olGreen = {0, 157, 87};
olRed = {238, 50, 78};
Graphics @ GraphicsComplex[
{{2.5, 0}, {1.3, -1}, {0, 0}, {5, 0}, {3.8, -1}},
ringSegment @@@
{{1, {0, 5/4 π}, olBlack},
{2, {0, π}, olyellow},
{3, {0, 2 π}, olblue},
{2, {-π 9/8, 1/4 π}, olyellow},
{4, {0, 5/4 π}, olRed},
{5, {0, 7/8 π}, olGreen},
{1, {5/4 π, 5/2 π}, olBlack},
{5, {7/8 π, 2 π}, olGreen},
{4, {-3/4 π, 1/4 π}, olRed}}
]
Why not create the 3D model of which this is a stylized representation?
To do so, we need to construct a 3D ring. Let's thicken a polygonal approximation to a circle:
ring[center_, normal_] :=
With[{a = axes[normal], radius = 1, thickness = 0.25},
Tube[center + radius {Cos[#], Sin[#]}.a & /@ Range[0, 2 Pi, 2 Pi / 72], thickness/2]];
The auxiliary function axes
is a quick-and-dirty way to obtain two orthonormal axes perpendicular to a particular direction. (It will not work in directions parallel to the y axis.) This makes it simpler and more natural to describe a 3D circle in terms of its center and a vector perpendicular to its plane:
axes[normal_] :=
Module[{x = {-normal[[3]], 0, normal[[1]]}, y},
y = Cross[normal, x]; {x / Norm[x], y / Norm[y]}];
Specify the positions of the centers and tilt the top row one way, the bottom row another:
dy = 2.4; offset = 0.25;
rings = Join[
ring[#, {0, -offset, 1}] & /@ {{0, 0, 0}, {0, dy, 0}, {0, 2 dy, 0}},
ring[#, {0, offset, 1}] & /@ {{Sqrt[3]/2, dy/2, 0}, {Sqrt[3]/2, 3 dy/2, 0}}];
Oh yes, the colors:
colors = {Cyan, Black, Red, Yellow, Green};
Render the rings:
Graphics3D[Riffle[colors, rings], Boxed -> False,
PlotRange -> {{-2, 4}, {-2, 3 dy}, {-2 offset, 2 offset}}]
Now you can play with them in three dimensions!
3 D approach
It would be possible to do this using ParametricPlot3D
, very slight variation in the $z$-direction, and a suitable ViewPoint
:
Stealing jVincent's colors:
olblue = RGBColor[{0, 129, 188}/255.];
olyellow = RGBColor[{255, 177, 49}/255.];
olBlack = RGBColor[{35, 34, 35}/255.];
olGreen = RGBColor[{0, 157, 87}/255.];
olRed = RGBColor[{238, 50, 78}/255.];
olyrings =
ParametricPlot3D[{{Cos[t], Sin[t], 0.325 Sin[t + Pi/4] - 0.035},
(* blue *){Cos[t], Sin[t], 0.325 Sin[t + Pi/4]},
{3/4 Pi + Cos[t], Sin[t], 0.04 Sin[t + Pi/4] - 0.005},
(* black *){3/4 Pi + Cos[t], Sin[t],
0.04 Sin[t + Pi/4]}, {3/8 Pi + Cos[t],
Sin[t] - 9/8, -0.12 Sin[Pi/4 - t] - 0.05},
(* yellow *){3/8 Pi + Cos[t],
Sin[t] - 9/8, -0.12 Sin[Pi/4 - t]}, {3/2 Pi + Cos[t], Sin[t],
0.005 Sin[t - Pi/4] - 0.001},
(* red *){3/2 Pi + Cos[t], Sin[t],
0.005 Sin[t - Pi/4]}, {9/8 Pi + Cos[t], Sin[t] - 9/8,
0.01 Sin[t - Pi/4] - 0.001},
(* green *){9/8 Pi + Cos[t], Sin[t] - 9/8, 0.01 Sin[t - Pi/4]}},
{t, 0, 2 Pi}, Axes -> False, BaseStyle -> AbsoluteThickness[10],
PlotStyle -> {Directive[AbsoluteThickness[14], White], olblue,
Directive[AbsoluteThickness[14], White], olBlack,
Directive[AbsoluteThickness[14], White], olyellow,
Directive[AbsoluteThickness[14], White], olRed,
Directive[AbsoluteThickness[14], White], olGreen},
ViewPoint -> Top, ImageSize -> 350, Boxed -> False,
PlotRangePadding -> 0.15]