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.

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

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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