13
$\begingroup$

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?

$\endgroup$

2 Answers 2

15
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ 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? $\endgroup$
    – 9527
    Commented Nov 4, 2013 at 1:34
  • $\begingroup$ @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). $\endgroup$
    – ybeltukov
    Commented Nov 4, 2013 at 14:19
6
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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