# Creating a certain image (3D shadows, highlighted intersections)

I would like to learn how to code within Mathematica the following picture:

I tried using

planarShadow[x_, direction_, normal_, darkShadow_: True] :=
Module[{d, n}, d = Normalize[direction];
n = Normalize[normal];
x /. Graphics3D[gr_, opts___] :>
GeometricTransformation[
gr /. {Glow[_] -> Glow[],
r_?(MemberQ[{RGBColor, Hue, CMYKColor, GrayLevel},
Composition[TranslationTransform[direction],
Quiet[RotationTransform[{d, n}], {RotationMatrix::degen,
RotationTransform::spln}], ScalingTransform[10^-3, d],
Quiet@Check[ScalingTransform[1./(n.d), n - (n.d) d],
Identity]]]}, opts]]

With[{cp3d =
ParametricPlot3D[{{u - 2, u^2, u^3}, {-u + 1, (1/2) u - 4,
u^2}, {Sin[u - 0.5], 2 u - 2, (1/10) u^3}, {u - 5, u, u}, {-u,
u + 2.5, -u}}, {u, -4, 4},
PlotStyle -> {Orange, Green, Yellow, Blue, Purple},
PlotRange -> {-4, 4}] /.
Line[pts_, rest___] :> Tube[pts, 0.4, rest]},
Show[cp3d, planarShadow[cp3d, {0, 0, -4.97}, {0, 0, -1}, True],
PlotRange -> {-5, 5}]]


and got a fairly inadequate comparison.

Any help would be appreciated.

• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. Aug 28, 2015 at 1:23
• For the right half with the 3D curves with white outlines, see my answer here.
– user484
Aug 28, 2015 at 2:57

Let us draw some random smooth curves:

pts = 4;
curves = 3;
SeedRandom[9];
f = Table[
Interpolation[Table[{t, RandomReal[1, {3}]}, {t, 0, 1, 1/pts}],
Method -> "Spline"], {curves}];
plot = ParametricPlot3D[
Evaluate@Table[f[[i]][t], {i, curves}], {t, 0, 1},
PlotPoints -> 300, MaxRecursion -> 0, PlotRange -> All,


After post-processing:

r = 0.020;
r2 = 1.3 r;
range = {{x1, x2}, {y1, y2}, {z1, z2}} = Chartingget3DPlotRange@plot;
shadows = Show[plot /. Line[pts_] :> {Black, Opacity[0.1], Tube[pts, r]},
Lighting -> {{"Ambient", White}}, ViewPoint -> {0, 0, ∞},
Boxed -> False, Axes -> False, PlotRange -> range];
img = ImageResize[Colorize[Rasterize[shadows, ImageSize -> 900],
ColorFunction -> (Hue[-# - 1/3, 1 - #^2] &)], Scaled[1/3]];
res = Show[Graphics3D[{EdgeForm[], Opacity[0.75], Texture[img],
Polygon[{{x1, y1, z2}, {x1, y2, z2}, {x2, y2, z2}, {x2, y1, z2}},
VertexTextureCoordinates -> {{0, 0}, {0, 1}, {1, 1}, {1, 0}}]}], plot /.
Line[pts_] :> {Tube[pts, r], FaceForm[Opacity[0], Glow[White]],
Tube[pts, r2]}, Lighting -> {{"Ambient", White}}, PlotRange -> range];
Style[Row@{img, res}, ImageSizeMultipliers -> {1, 1}]


Post-processing consists of two separate parts:

White outlines is a thicker copy of curves, which is transparent outside and white inside (see Rahul's answer here or my answer here). Curves are flattened with Lighting -> {{"Ambient", White}}. I also use Chartingget3DPlotRange to automatically obtain plot range (see here). You can put some fixed values there.