13

I draw a Graphics3D object of two tubes:

Graphics3D[{Tube[{{-0.2, -1, 0}, {-0.2, 1, 0}}, 0.05], 
    Tube[{{0, 0, -1}, {0, 0, 1}}, 0.05]}, Boxed -> False]

And I get this:

enter image description here

Now I want to have some edge effect of the two tubes, so that more parts of the back tube are excluded by the front tube, with the desired result like this:

enter image description here

Replacing Tube[a_] by {EdgeForm[{White,Thick}],Tube[a]} does not work, is there a simple way to do?

9527
  • 529
  • 2
  • 11

2 Answers2

15

You can add a tube around each of your tubes with a slightly bigger radius, transparent outer color, and white inner color.

t1 = Tube[{{-0.2, -1, 0}, {-0.2, 1, 0}}, 0.05];
t2 = Tube[{{0, 0, -1}, {0, 0, 1}}, 0.05];

Graphics3D[{t1, t2, FaceForm[None, Glow[White]], 
   MapAt[1.8 # &, #, 2] & /@ {t1, t2}}, Boxed -> False]

enter image description here

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
ybeltukov
  • 43,673
  • 5
  • 108
  • 212
  • Thanks, this is what I want. However, I have a new question based on your answer. If I replace the tube t1 by an arrowed tube ``, then the Faceform does not apply to the arrowheads. For example, t1 = {Arrowheads[{0.1}], Arrow[Tube[{{-0.2, -1, 0}, {-0.2, 1, 0}}, 0.05]]}; Graphics3D[{FaceForm[None, Glow[White]], t1}, Boxed -> False] will leave the arrowhead visible. Why it does not apply to arrowhead? – 9527 Nov 04 '13 at 01:34
  • @9527 Arrowhead for unknown reasons takes into account only regular color, not FaceForm. Try to play with Cone[], it works well with FaceForm. You can also set it as a custom arrowhead (see documentation). – ybeltukov Nov 04 '13 at 14:19
6

ybeltukov's basic idea is certainly the way to go, but I think -- for easier general application -- it is a good idea to capture it into a function. So I would write

ghostTube[t_Tube, factor_?NumericQ] := 
  {FaceForm[None, Glow[White]], Tube[t[[1]], factor t[[2]]]}

and apply it like this

Module[{t1, t2},
  t1 = Tube[{{-0.2, -1, 0}, {-0.2, 1, 0}}, 0.05]; 
  t2 = Tube[{{0, 0, -1}, {0, 0, 1}}, 0.05];
  Graphics3D[{t1, t2, ghostTube[#, 1.5] & /@ {t1, t2}}, Boxed -> False]]

tubes.png

m_goldberg
  • 107,779
  • 16
  • 103
  • 257