TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to draw multiple colored one-dimensional parametric curves in three dimensional euclidean space. The curves themselves do not intersect in 3d, but sometimes their projections intersect when projected into 2d for visualization. In these cases, I would like the color at the intersection to be the color of the curve 'in front.'

The problem is that the curves are not strictly ordered (they could be knot-like) so I have some variant of the painter's problem, except a bit simpler because all my objects are one-dimensional and they do not intersect in 3d.

Is there a nice LaTeX or related thing that could help me with this? I've looked at examples for asymptote and some other ps and tikz packages but I can't find a nice example where this is done automatically.

Currently my work-around is to break all of the curves into tiny segments and then depth sort. This works as long as the segments are small relative to the minimum distance between curves in 3d, I think. But it is a hack and is ugly.

share|improve this question
Try to visit PSTricks 3D Examples and PSTricks 3D Gallery‌​. – xport Jul 13 '11 at 16:26
I believe even all the PSTricks examples showing this, doesn't sort, or sorts manually. – Mikael Öhman Jul 13 '11 at 16:34
PSTricks can draw lines with hidden elements. – Herbert Jul 13 '11 at 17:22
@Herbert; But does it do correct Z-buffering? The 3D-wave example shows exactly the problem addressed in the question. – Mikael Öhman Jul 13 '11 at 18:30
@Mikael: How should we then draw 3d elements with hidden lines and surfaces? melusine.eu.org/syracuse/pstricks/pst-solides3d/doc/… – Herbert Jul 13 '11 at 18:36

Doing these computations in tex is usually not a pretty sight, so Z-ordering is mostly absent in these plotting tools. I believe you need to look into an external tool, like sketch which can generate the tikz code for you.

share|improve this answer

Your Answer


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.