Next: , Previous: Drawing a solid, Up: Introduction by example



2.4 Special objects

We can add labels to a drawing by using special objects, which provide a way to embed raw LaTeX and PSTricks code. Adding this to the tetrahedron does the trick.

  special |\footnotesize
           \uput{2pt}[ur]#1{$P1$}
           \uput[r]#2{$P2$}
           \uput[u]#3{$P3$}
           \uput[d]#4{$P4$}|
    (p1)(p2)(p3)(p4)
Here is the result.
ex042.png

There are several details to note here. First, the quoting convention for the raw code is similar to the LaTeX \verb command. The first non-white space character following special is understood to be the quote character, in this case |. The raw text continues until this character recurs.

Second, the argument references #1, #2, #3, and #4 refer to points in the list that follow. This is similar to TeX macro syntax. The transformed and two-dimensional projections of these three-dimensional points are substituted in the final output. An argument reference of the form #1-2 is replaced with the angle in degrees of the two-dimensional vector that connects the projections of the two respective argument points, here #1 and #2. The substituted angle is enclosed in curly braces { }

By default, special objects are printed last, overlaying all other objects in the scene. If you specify the internal option lay=in, the hidden surface algorithm considers the entire special object to be the first point (#1) in the argument list. If that point is behind (of smaller z-component than) any drawable, then the entire special object is drawn before that drawable, so the drawable obscures parts of the special object that overlaps it. In our example, p1 is the front-most point in the scene (has the largest z-component), so adding lay=in has no effect.

With option lay=under, a special is drawn before, hence appears under any of the objects handled by the hidden surface algorithm. This is how the light gray axes were added to the “hello world” example Hello world.

Special objects are powerful, with many possible uses.