Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 11 down vote accepted

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

share|improve this answer
    
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 4 '13 at 1: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 4 '13 at 14:19
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.