PSTricks 代码无法编译

PSTricks 代码无法编译

下面的代码尝试扩展 Herbert 的图形这里

\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}

(在我的计算机上,使用 XeLaTeX 编译代码大约需要 25 秒。)

她的错误是:

[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"
 )

我需要做哪些更改才能使代码可编译?我该如何修复这个问题?

更新

在 Werner 的帮助下,我最终得到了以下结果:

\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}

答案1

您的实体S4T4都设置在仅由 2 个维度(-3,-0.9)/组成的位置,而您需要 3 个维度。我在下面的 MWE 中使用/(3,-0.9)完成了此操作:(-3,0,-0.9)(3,0,-0.9)

在此处输入图片描述

\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}

您还可以更改视点,从相同距离查看链条。下面我使用了viewpoint=0 -40 0

在此处输入图片描述

\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}

请注意,由于您使用笛卡尔坐标系在 3D 中放置对象,因此我坚持使用笛卡尔坐标系来放置视点(放弃转换rtp2xyz)。


鉴于理解viewpoint(以及可能的光源lightsrc)有些困难,这里有一个动画图形,固定的光源位于 (x,y,z)=(0,-40,0) 处,并且移动视点(球坐标系)以 10 度为增量围绕物体,起始于40 90 0 rtp2xyz

在此处输入图片描述

答案2

您的圆环沿 x 轴放置。如果您希望两个圆环大小相同,则必须沿 y 轴查看!

viewpoint=40 90 20 rtp2xyz

即:radius=40theta=90(绕 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}

在此处输入图片描述

相关内容