如何在 LaTeX 中绘制棋盘圆环(甜甜圈)?我看过绘制圆环的示例。但我还需要$4 \cross 4$
在上面制作棋盘。如果我也可以更改配色方案,那会更有帮助!
答案1
使用 xelatex 运行。我不太明白你想把棋盘放在哪里。
\documentclass{article}
\usepackage{pst-solides3d}
\begin{document}
\psset{Decran=20,lightsrc=10 20 20 rtp2xyz}
\psframebox{%
\begin{pspicture}(-5,-4)(5,3)
\psSolid[
r1=2.5,r0=1.5,
object=tore,
ngrid=18 36,
fillcolor=green!30,
action=draw**]
\end{pspicture}}
\end{document}
以及带有 4x4 方格的棋盘:
\documentclass{article}
\usepackage{pst-solides3d}
\begin{document}
\begin{pspicture}(-3,-3)(3.5,2.5)
\psset{Decran=20,RotZ=-160}
\psSolid[
object=tore,
fcol = 0 256 768 { /i ED
i 8 i 32 add { dup 3 add 1 exch { 32 i 127 add { (Black) } for } for } for } for
132 256 900 { /i ED
i 8 i 32 add { dup 3 add 1 exch { 32 i 127 add { (Black) } for } for } for } for,
r1=2.5, r0=1.5, ngrid=32 32, %numfaces=all,fontsize=5,
linewidth=0.1pt]
\end{pspicture}
\end{document}
或者法国万岁......:-)
\documentclass{article}
\usepackage{pst-solides3d}
\begin{document}
\begin{pspicture}(-3,-3)(3.5,2.5)
\psset{Decran=20,RotZ=-160}
\psSolid[
object=tore,
fcol = 0 256 768 { /i ED
i 8 i 32 add { dup 3 add 1 exch { 32 i 127 add { (Blue) } for } for } for } for
132 256 900 { /i ED
i 8 i 32 add { dup 3 add 1 exch { 32 i 127 add { (Red) } for } for } for } for,
r1=2.5, r0=1.5, ngrid=32 32, %numfaces=all,fontsize=5,
linewidth=0.1pt]
\end{pspicture}
\end{document}
答案2
使用绘制圆环pst-solides3d
包裹,例如赫伯特的回答,是可能的。您可以将其扩展到下面的代码,该代码在圆环上嵌入了一个 4x4 的黑红棋盘。
\documentclass{article}
\usepackage{pst-solides3d}% http://ctan.org/pkg/pst-solides3d
\begin{document}
\begin{pspicture}(-3,-3)(3.5,2.5)
\psset{Decran=20,viewpoint=10 10 15}%,lightsrc=10 10 20 rtp2xyz,lightintensity=1
\pstVerb{/iface 0 store}%
\psSolid[
fcol=4 {%
iface (Black) iface 1 add (Black) iface 2 add (Black) iface 3 add (Black)
iface 4 add (Red) iface 5 add (Red) iface 6 add (Red) iface 7 add (Red)
iface 8 add (Black) iface 9 add (Black) iface 10 add (Black) iface 11 add (Black)
iface 12 add (Red) iface 13 add (Red) iface 14 add (Red) iface 15 add (Red)
iface 64 add (Red) iface 65 add (Red) iface 66 add (Red) iface 67 add (Red)
iface 68 add (Black) iface 69 add (Black) iface 70 add (Black) iface 71 add (Black)
iface 72 add (Red) iface 73 add (Red) iface 74 add (Red) iface 75 add (Red)
iface 76 add (Black) iface 77 add (Black) iface 78 add (Black) iface 79 add (Black)
iface 128 add (Black) iface 129 add (Black) iface 130 add (Black) iface 131 add (Black)
iface 132 add (Red) iface 133 add (Red) iface 134 add (Red) iface 135 add (Red)
iface 136 add (Black) iface 137 add (Black) iface 138 add (Black) iface 139 add (Black)
iface 140 add (Red) iface 141 add (Red) iface 142 add (Red) iface 143 add (Red)
iface 192 add (Red) iface 193 add (Red) iface 194 add (Red) iface 195 add (Red)
iface 196 add (Black) iface 197 add (Black) iface 198 add (Black) iface 199 add (Black)
iface 200 add (Red) iface 201 add (Red) iface 202 add (Red) iface 203 add (Red)
iface 204 add (Black) iface 205 add (Black) iface 206 add (Black) iface 207 add (Black) /iface
iface 16 add store}
repeat,
r1=4,r0=1,% Inner radius and torus radius
object=tore,% Object is a torus
ngrid=16 16,% Grid definition
linewidth=0.1pt,% Edge line width
% grid,% Remove edges
% RotY=30% Rotation about y-axis (RotX and RotZ for rotations about x- and z-axis)
]
\end{pspicture}
\end{document}
这fcol=... repeat
部分指定了面颜色。仅使用 4x4 网格会使圆环看起来像正方形。因此,我将其提升到 16x16 网格圆环。然而,这增加了一堆面颜色规范,这不能嵌套以使其更容易。它仍然可行,但很麻烦。你追求的表面越平滑,你需要添加的着色面就越多。grid
在你的\psSolid[...]
定义中添加选项会删除边缘,并产生
实体的所有渲染/处理都是在 Postscript 端进行的。这意味着编译会很快,但加载到查看器中可能会有点慢。但是,一旦您对圆环的外观感到满意,您就可以将顶点和面导出到文件中,然后直接加载它们。这大大加快了查看速度。
在上面的例子中,选择颜色是为了突出圆环的定义。选择白色而不添加边缘效果不佳,所以也许一些灰白色会起作用。此外,您可以修改视点和/或轴旋转。请参阅包装文档了解有关这些参数的更多信息。