[Tex/LaTex] Creating figures of polytopes (in 3D): Is it worth switching from PSTricks to TikZ

pstrickstikz-pgf

I used PSTricks a lot to create figures of polytopes. More recently, I have become aware of discussions going on about whether PSTricks or TikZ is the better choice for creating figures of all kinds. From the general discussion on this issue, I have come to the conclusion that I want to use TikZ rather than PSTricks in the future.

However, before I switch to TikZ, I want to find out whether TikZ is good for the particular purpose I want to use it for. I mainly used the pst-solides3d package of PSTricks, and I wonder whether TikZ provides substitutes for the features of PSTricks I used. To make my question more conrete, let me just give a very simple example of a polytope that I created with PSTricks and give you a list of features that I like in this example, and you tell me whether the particular features are easily implemented in TikZ.

\documentclass{minimal}
\usepackage{pst-solides3d}
\begin{document}

\begin{pspicture}(-2.5,-1)(6,4)
\psset{viewpoint=40 16 12,Decran=130,solidmemory}
\psSolid[object=new,linewidth=0.7\pslinewidth,
 action=draw*,
 name=A,
 fcol=1 (0.8 setgray),
 sommets= 
  %n=4
  0 0 0 %0
  0.420448  0.420448 0.5 %e1
 -0.420448  0.420448 0.5 %e2
 -0.420448 -0.420448 0.5 %e3
  0.420448 -0.420448 0.5 %e4
  0 0 1.2, %u
 faces={
  [1 2 3 4]
  [1 2 5]
  [2 3 5]
  [3 4 5]
  [4 1 5]}]%
\psSolid[object=plan,definition=solidface,action=none,args=A 0,name=S0]
\psset{fontsize=8}
\psProjection[object=texte,text={G},plan=S0]%
\psSolid[object=plan,definition=solidface,action=none,args=A 1,name=S1]
\psProjection[object=texte,text={H},phi=90,plan=S1]%
\psPoint(0, 0, 1.2){a}
\uput[u](a){$a_G$}
\psdot[dotsize=0.1](a)
\end{pspicture}

\end{document}

polytope example

What I like about it:

  1. I can create the polytope from a given set of three-dimensional coordinates.
  2. If I want to change the viewpoint, I don't have to type in the code of a whole new polytope but I simply change \psset{viewpoint=40 16 12,Decran=130}.
  3. The hidden lines are dashed. Important: I don't have to specify which lines are hidden; determining the hidden lines should be automatic.
  4. I can write text on the faces of the polytope (like G, H in this example).
  5. I can easily color a face (like giving the H-face a gray color).
  6. The corners are easily marked (with a dot) and labeled (a_G in the example).

Is this easily done using TikZ? An example creating this polytope with the mentioned features using TikZ would be nice (this would also help me to start using TikZ if I should decide to switch). I think if these basic things work with TikZ, then I can cope with other details that may or may not be possible with TikZ.

EDIT: Answering the question of what would be "the most complicated" polytope I might want to draw: I don't know. Although I don't know TikZ, I would gess that increasing complexity in terms of an increasing number of coordinates / corners should not be problematic (is it?). Of course it's more labor-intensive to type the code (needless to say that this is also true for pstricks), but I think the general feasibility should not be affected by that (right?). That's why I focused on features instead of on the complexity of the polytope. One thing I can say is that I will probably only draw convex polytopes. I might want to draw more complicated polytopes in the future, but the most complicated one I have drawn so far is probably this one (yes, the additional septagon on top is intended):

    \documentclass{minimal}

\usepackage{pst-solides3d}

\begin{document}

\begin{pspicture}[showgrid=false](-2,-0.5)(2,2.7)
\psset{viewpoint=26 7 5,Decran=50}
\psSolid[object=new, linewidth=0.7\pslinewidth,
action=draw*,
name=A,
sommets=
%n=7
0 0 0 %0 0
0.656862 0.82368 1 %w1 1
-0.234432 1.02711 1 %w2 2
-0.949194 0.457108 1 %w3 3
-0.949194 -0.457108 1 %w4 4
-0.234432 -1.02711 1 %w5 5
0.656862 -0.82368 1 %w6 6
1.05353 0 1 %w7 7
0.311322 0.390385 0.473952 %e1 8
-0.111109 0.486802 0.473952 %e2 9
-0.449873 0.216647 0.473952 %e3 10
-0.449873 -0.216647 0.473952 %e4 11
-0.111109 -0.486802 0.473952 %e5 12
0.311322 -0.390385 0.473952 %e6 13
0.499321 0 0.473952 %e7 14
-0.311322 -0.390385 0.526048 %u-e1 15
0.111109 -0.486802 0.526048 %u-e2 16
0.449873 -0.216647 0.526048 %u-e3 17
0.449873 0.216647 0.526048 %u-e4 18
0.111109 0.486802 0.526048 %u-e5 19
-0.311322 0.390385 0.526048 %u-e6 20
-0.499321 0 0.526048 %u-e7 21
0 0 1, %u 22
faces={
[0 13 16 12]
[0 12 15 11]
[0 11 21 10]
[0 10 20 9]
[0 9 19 8]
[0 8 18 14]
[0 14 17 13]
[16 13 17 22]
[17 14 18 22]
[18 8 19 22]
[19 9 20 22]
[20 10 21 22]
[21 11 15 22]
[15 12 16 22]
[1 2 3 4 5 6 7]
}]
\end{pspicture}

\end{document}

second polytope example

At this example, one can see why it is useful that hidden lines are dashed: If they were solid, the picture would not be as readable as this one.

Best Answer

it may make sense in the future when TikZ will use the Lua extensions for calculations of hidden lines and surfaces. Then it may be possible to do with Lua the same as you can do with the programming language PostScript.

Related Question