5

The following code is an attempt to extend Herbert's figure here:

\documentclass[
  dvipsnames
]{article}

\usepackage[
  hmargin=2.4cm,
  vmargin=3cm
]{geometry}
\usepackage{pst-solides3d}

\pagestyle{empty}

\begin{document}

\begin{center}
  \begin{pspicture}[solidmemory](-5.9,-7.95)(5.9,10.45)
   \psset{
     lightsrc=viewpoint,
     viewpoint=40 -10 0 rtp2xyz,
     Decran=100,
     grid=false,
     object=tore,
     r0=0.2,
     action=none
   }
    \psSolid[r1=1,  ngrid=10 50,        RotY=90,        fillcolor=blue,  name=S1](-3,0,3)
    \psSolid[r1=0.9,ngrid=10 45,RotX=90,        RotZ=30,fillcolor=green, name=S2](-3,0,1.5)
    \psSolid[r1=0.8,ngrid=10 40,        RotY=90,        fillcolor=red,   name=S3](-3,0,0.2)
    \psSolid[r1=0.7,ngrid=10 35,RotX=90,        RotZ=30,fillcolor=gray,  name=S4](-3,-0.9)
    \psSolid[r1=0.6,ngrid=10 30,        RotY=90,        fillcolor=yellow,name=S5](-3,0,-1.8)
    \psSolid[r1=0.5,ngrid=10 25,RotX=90,        RotZ=30,fillcolor=Purple,name=S6](-3,0,-2.5)
    \psSolid[
      object=fusion,
      base=S1 S2 S3 S4 S5 S6,
      linewidth=0.1pt,
      linecolor=black!60,
      action=draw**
    ]
    \psSolid[r1=1,  ngrid=10 50,        RotY=90,        fillcolor=blue,  name=T1](3,0,3)
    \psSolid[r1=0.9,ngrid=10 45,RotX=90,        RotZ=30,fillcolor=green, name=T2](3,0,1.5)
    \psSolid[r1=0.8,ngrid=10 40,        RotY=90,        fillcolor=red,   name=T3](3,0,0.2)
    \psSolid[r1=0.7,ngrid=10 35,RotX=90,        RotZ=30,fillcolor=gray,  name=T4](3,-0.9)
    \psSolid[r1=0.6,ngrid=10 30,        RotY=90,        fillcolor=yellow,name=T5](3,0,-1.8)
    \psSolid[r1=0.5,ngrid=10 25,RotX=90,        RotZ=30,fillcolor=Purple,name=T6](3,0,-2.5)
    \psSolid[
      object=fusion,
      base=T1 T2 T3 T4 T5 T6,
      grid=false,
      linewidth=0.1pt,
      linecolor=black!60,
      action=draw**
    ]
  \end{pspicture}
\end{center}

\end{document}

(It takes about 25 seconds to compile the code, using XeLaTeX, on my computer.)

Her is the error:

[1] (./test.aux)Error: /typecheck in --add--
Operand stack:
   les_sommets   --nostringval--   0.0   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1884   1   3   %oparray_pop   1883   1   3   %oparray_pop   1867   1   3   %oparray_pop   1755   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   --nostringval--   359   --nostringval--   %repeat_continue   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1175/1684(ro)(G)--   --dict:0/20(G)--   --dict:117/200(L)--   --dict:754/1012(L)--   --dict:206/300(L)--   --dict:754/1012(L)--   --dict:2/3(L)--   --dict:3/3(L)--   --dict:6/6(L)--
Current allocation mode is local
Last OS error: Not a directory
Current file position is 10322
GPL Ghostscript 9.10: Unrecoverable error, exit code 1

** WARNING ** Filtering file via command -->rungs -q -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -sOutputFile='/tmp/dvipdfmx.XXFBpfjq' '/tmp/dvipdfmx.XXat2UdM' -c quit<-- failed.
** WARNING ** Image format conversion for PSTricks failed.
** WARNING ** Interpreting special command pst: (ps:) failed.
** WARNING ** >> at page="1" position="(306, 410.74)" (in PDF)
** WARNING ** >> xxx "pst:  tx@Dict begin STP newpath   1. .setopacityalpha  1 setlin"
 )

What do I have to change to make the code compilable? How do I fix this?

Update

After help from Werner, the following is what I ended up with:

\documentclass[
  dvipsnames
]{article}

\usepackage[
  hmargin=2.4cm,
  vmargin=3cm
]{geometry}
\usepackage{pst-solides3d}

\pagestyle{empty}

\begin{document}

\begin{center}
  \begin{pspicture}[solidmemory](-4.8,-7.75)(4.8,10.2)
   \psset{
     lightsrc=viewpoint,
     Decran=100,
     object=tore,
     r0=0.2,
     action=none
   }
    \psSolid[r1=1,  ngrid=10 50,        RotY=90,       fillcolor=blue,  name=S1](-1.5,0,3)
    \psSolid[r1=0.9,ngrid=10 45,RotX=90,        RotZ=0,fillcolor=green, name=S2](-1.5,0,1.5)
    \psSolid[r1=0.8,ngrid=10 40,        RotY=90,       fillcolor=red,   name=S3](-1.5,0,0.2)
    \psSolid[r1=0.7,ngrid=10 35,RotX=90,        RotZ=0,fillcolor=gray,  name=S4](-1.5,0,-0.9)
    \psSolid[r1=0.6,ngrid=10 30,        RotY=90,       fillcolor=yellow,name=S5](-1.5,0,-1.8)
    \psSolid[r1=0.5,ngrid=10 25,RotX=90,        RotZ=0,fillcolor=Purple,name=S6](-1.5,0,-2.5)
    \psSolid[
      viewpoint=40 45 0 rtp2xyz,
      object=fusion,
      base=S1 S2 S3 S4 S5 S6,
      grid=false,
      action=draw**
    ]
    \psSolid[r1=1,  ngrid=10 50,        RotY=90,       fillcolor=blue,  name=T1](1.5,0,3)
    \psSolid[r1=0.9,ngrid=10 45,RotX=90,        RotZ=0,fillcolor=green, name=T2](1.5,0,1.5)
    \psSolid[r1=0.8,ngrid=10 40,        RotY=90,       fillcolor=red,   name=T3](1.5,0,0.2)
    \psSolid[r1=0.7,ngrid=10 35,RotX=90,        RotZ=0,fillcolor=gray,  name=T4](1.5,0,-0.9)
    \psSolid[r1=0.6,ngrid=10 30,        RotY=90,       fillcolor=yellow,name=T5](1.5,0,-1.8)
    \psSolid[r1=0.5,ngrid=10 25,RotX=90,        RotZ=0,fillcolor=Purple,name=T6](1.5,0,-2.5)
    \psSolid[
      viewpoint=40 135 0 rtp2xyz,
      object=fusion,
      base=T1 T2 T3 T4 T5 T6,
      linewidth=0.1pt,
      linecolor=black!60,
      action=draw**
    ]
  \end{pspicture}
\end{center}

\end{document}
3
  • it makes no sense to set the viewpoint for the fusion object. It should be set before all objects which depend on that setting. – user2478 Oct 31 '13 at 7:51
  • @Herbert Any chance I can make you give an answer with the correct way of doing this? – Svend Tveskæg Oct 31 '13 at 11:53
  • see my answer ... – user2478 Oct 31 '13 at 14:34
7

Your solids S4 and T4 are both set at locations consisting of only 2 dimensions (-3,-0.9)/(3,-0.9) while you need 3 dimensions. I've done so using (-3,0,-0.9)/(3,0,-0.9) in the MWE below:

enter image description here

\documentclass[
  dvipsnames
]{article}

\usepackage[
  hmargin=2.4cm,
  vmargin=3cm
]{geometry}% http://ctan.org/pkg/geometry
\usepackage{pst-solides3d}% tug.org/PSTricks/main.cgi/

\pagestyle{empty}

\begin{document}

\begin{center}
  \begin{pspicture}[solidmemory](-5.9,-7.95)(5.9,10.45)
   \psset{
     lightsrc=viewpoint,
     viewpoint=40 -10 0 rtp2xyz,
     Decran=100,
     grid=false,
     object=tore,
     r0=0.2,
     action=none
   }
    \psSolid[r1=1,  ngrid=10 50,        RotY=90,        fillcolor=blue,  name=S1](-3,0,3)
    \psSolid[r1=0.9,ngrid=10 45,RotX=90,        RotZ=30,fillcolor=green, name=S2](-3,0,1.5)
    \psSolid[r1=0.8,ngrid=10 40,        RotY=90,        fillcolor=red,   name=S3](-3,0,0.2)
    \psSolid[r1=0.7,ngrid=10 35,RotX=90,        RotZ=30,fillcolor=gray,  name=S4](-3,0,-0.9)
    \psSolid[r1=0.6,ngrid=10 30,        RotY=90,        fillcolor=yellow,name=S5](-3,0,-1.8)
    \psSolid[r1=0.5,ngrid=10 25,RotX=90,        RotZ=30,fillcolor=Purple,name=S6](-3,0,-2.5)
    \psSolid[
      object=fusion,
      base=S1 S2 S3 S4 S5 S6,
      linewidth=0.1pt,
      linecolor=black!60,
      action=draw**
    ]
    \psSolid[r1=1,  ngrid=10 50,        RotY=90,        fillcolor=blue,  name=T1](3,0,3)
    \psSolid[r1=0.9,ngrid=10 45,RotX=90,        RotZ=30,fillcolor=green, name=T2](3,0,1.5)
    \psSolid[r1=0.8,ngrid=10 40,        RotY=90,        fillcolor=red,   name=T3](3,0,0.2)
    \psSolid[r1=0.7,ngrid=10 35,RotX=90,        RotZ=30,fillcolor=gray,  name=T4](3,0,-0.9)
    \psSolid[r1=0.6,ngrid=10 30,        RotY=90,        fillcolor=yellow,name=T5](3,0,-1.8)
    \psSolid[r1=0.5,ngrid=10 25,RotX=90,        RotZ=30,fillcolor=Purple,name=T6](3,0,-2.5)
    \psSolid[
      object=fusion,
      base=T1 T2 T3 T4 T5 T6,
      grid=false,
      linewidth=0.1pt,
      linecolor=black!60,
      action=draw**
    ]
  \end{pspicture}
\end{center}

\end{document}

You could also change the viewpoint to see the chains from the same distance. Below I've used viewpoint=0 -40 0:

enter image description here

\documentclass[
  dvipsnames
]{article}

\usepackage[
  hmargin=2.4cm,
  vmargin=3cm
]{geometry}% http://ctan.org/pkg/geometry
\usepackage{pst-solides3d}% tug.org/PSTricks/main.cgi/

\pagestyle{empty}

\begin{document}

\begin{center}
  \begin{pspicture}[solidmemory](-5.9,-7.95)(5.9,10.45)
   \psset{
     lightsrc=viewpoint,
     viewpoint=0 -40 0,
     Decran=100,
     grid=false,
     object=tore,
     r0=0.2,
     action=none
   }
    \psSolid[r1=1,  ngrid=10 50,        RotY=90,        fillcolor=blue,  name=S1](-3,0,3)
    \psSolid[r1=0.9,ngrid=10 45,RotX=90,        RotZ=30,fillcolor=green, name=S2](-3,0,1.5)
    \psSolid[r1=0.8,ngrid=10 40,        RotY=90,        fillcolor=red,   name=S3](-3,0,0.2)
    \psSolid[r1=0.7,ngrid=10 35,RotX=90,        RotZ=30,fillcolor=gray,  name=S4](-3,0,-0.9)
    \psSolid[r1=0.6,ngrid=10 30,        RotY=90,        fillcolor=yellow,name=S5](-3,0,-1.8)
    \psSolid[r1=0.5,ngrid=10 25,RotX=90,        RotZ=30,fillcolor=Purple,name=S6](-3,0,-2.5)
    \psSolid[
      object=fusion,
      base=S1 S2 S3 S4 S5 S6,
      linewidth=0.1pt,
      linecolor=black!60,
      action=draw**
    ]
    \psSolid[r1=1,  ngrid=10 50,        RotY=90,        fillcolor=blue,  name=T1](3,0,3)
    \psSolid[r1=0.9,ngrid=10 45,RotX=90,        RotZ=30,fillcolor=green, name=T2](3,0,1.5)
    \psSolid[r1=0.8,ngrid=10 40,        RotY=90,        fillcolor=red,   name=T3](3,0,0.2)
    \psSolid[r1=0.7,ngrid=10 35,RotX=90,        RotZ=30,fillcolor=gray,  name=T4](3,0,-0.9)
    \psSolid[r1=0.6,ngrid=10 30,        RotY=90,        fillcolor=yellow,name=T5](3,0,-1.8)
    \psSolid[r1=0.5,ngrid=10 25,RotX=90,        RotZ=30,fillcolor=Purple,name=T6](3,0,-2.5)
    \psSolid[
      object=fusion,
      base=T1 T2 T3 T4 T5 T6,
      grid=false,
      linewidth=0.1pt,
      linecolor=black!60,
      action=draw**
    ]
  \end{pspicture}
\end{center}

\end{document}

Note that since you're placing the objects in 3D using Cartesian coordinates, I've stuck with Cartesian coordinates for placement of the viewpoint (dropping the conversion rtp2xyz).


In light of some difficulty understanding the viewpoint (and possibly the light source lightsrc), here is an animated graphic with a fixed light source at (x,y,z)=(0,-40,0) and moving the viewpoint (in spherical coordinates) around the object in 10 degree increments, starting from 40 90 0 rtp2xyz:

enter image description here

6
  • Thank you, Werner! I now have a follow-up question (see updated question). – Svend Tveskæg Oct 30 '13 at 3:00
  • @SvendTveskæg: That's because you are viewing the solids in 3D based on a specific viewpoint. Specifically your viewpoint is set to be "far over in the x-direction" (since x = 40), implying that you're closer to the T-object. And closer objects appear larger, while further objects appear smaller. For an equal view on the objects, you should probably use viewpoint=0 -10 0 rtp2xyz. – Werner Oct 30 '13 at 3:05
  • Then (1) the chains are top of each other, (2) one of them are up-side down, and (3) one is still bigger than the other; I'll try to fiddle with it and return. – Svend Tveskæg Oct 30 '13 at 3:11
  • @SvendTveskæg: I just noticed you're actually transforming your coordinates from spherical rtp to Cartesian xyz. How about just using Cartesian: viewpoint=0 -40 0 (just a guess). Experimentation would yield the best solution... – Werner Oct 30 '13 at 3:15
  • That produces an error. – Svend Tveskæg Oct 30 '13 at 3:17
3

Your rings are placed along the x-axis. If you want both in the same size then you have to view it along the y-axis!

viewpoint=40 90 20 rtp2xyz

which is: radius=40, theta=90 (rotation around z), phi=20

\documentclass[dvipsnames]{article}
\usepackage{pst-solides3d}
\begin{document}

\begin{center}
  \begin{pspicture}[solidmemory](-4.8,-7.75)(4.8,10.2)
   \psset{viewpoint=40 90 20 rtp2xyz,lightsrc=viewpoint,
     Decran=100,object=tore,r0=0.2,action=none}
    \axesIIID(4,4,4)
    \psSolid[r1=1,  ngrid=10 50,        RotY=90,       fillcolor=blue,  name=S1](-1.5,0,3)
    \psSolid[r1=0.9,ngrid=10 45,RotX=90,        RotZ=0,fillcolor=green, name=S2](-1.5,0,1.5)
    \psSolid[r1=0.8,ngrid=10 40,        RotY=90,       fillcolor=red,   name=S3](-1.5,0,0.2)
    \psSolid[r1=0.7,ngrid=10 35,RotX=90,        RotZ=0,fillcolor=gray,  name=S4](-1.5,0,-0.9)
    \psSolid[r1=0.6,ngrid=10 30,        RotY=90,       fillcolor=yellow,name=S5](-1.5,0,-1.8)
    \psSolid[r1=0.5,ngrid=10 25,RotX=90,        RotZ=0,fillcolor=Purple,name=S6](-1.5,0,-2.5)
    \psSolid[object=fusion,base=S1 S2 S3 S4 S5 S6,grid,action=draw**]
    \psSolid[r1=1,  ngrid=10 50,        RotY=90,       fillcolor=blue,  name=T1](1.5,0,3)
    \psSolid[r1=0.9,ngrid=10 45,RotX=90,        RotZ=0,fillcolor=green, name=T2](1.5,0,1.5)
    \psSolid[r1=0.8,ngrid=10 40,        RotY=90,       fillcolor=red,   name=T3](1.5,0,0.2)
    \psSolid[r1=0.7,ngrid=10 35,RotX=90,        RotZ=0,fillcolor=gray,  name=T4](1.5,0,-0.9)
    \psSolid[r1=0.6,ngrid=10 30,        RotY=90,       fillcolor=yellow,name=T5](1.5,0,-1.8)
    \psSolid[r1=0.5,ngrid=10 25,RotX=90,        RotZ=0,fillcolor=Purple,name=T6](1.5,0,-2.5)
    \psSolid[object=fusion,base=T1 T2 T3 T4 T5 T6,grid,action=draw**]
  \end{pspicture}
\end{center}

\end{document}

enter image description here

0

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.