Q:

How can solides3d know when one object is behind another?

pst-solides3d has an impressive graphics engine behind its design. I'm interested in knowing how it is able to know when an object is behind another object.
Disclaimer: I am not sure this is an acceptable question for tex.SX because I'm trying to delve into the internal workings of a package. If this is an inappropriate question or this is the wrong forum, please let me know and I will delete the question.
I understand that solids in this package are first represented in a virtual 3D space and that they are later projected onto a 2D (user defined) projection screen. I think, it is in this step that the clipping (or superpositioning) of objects occurs.
So, to simplify the question, what mechanism does pst-solides3d use to find out if one object is behind the other (or intersecting)?
PS: I use the tag package-writing because this question is related to the writing of a package, but I am not interested in writing packages nor do I have the time for it at the moment

A:

A surface is divided into more or less small rectangles. For every small rectangles you can build the direction vector. The angle of this 3D vector and the distance from the origin allows to sort all rectangles. A direction vector which shows into the paper plane marks an invisible area. If it shows out of the paper plane it marks a visible area. These areas are sorted from the back to the front and also drawn in this way.

