由于pst-3dplot
没有命名的 3D 点(又称 3D 节点),我必须使用以下宏。不幸的是,扩展令人困惑。你能修复它吗?
\documentclass[pstricks,border=1cm,12pt]{standalone}
\usepackage{pst-3dplot}
\psset
{
Alpha=30,
Beta=30,
}
\begin{document}
\begin{pspicture}[showgrid=true](-5,-5)(10,10)
\pstThreeDCoor
[
xMin=-1,
xMax=5,
yMin=-1,
yMax=5,
zMin=-1,
zMax=5,
IIIDticks,
IIIDticksize=.1,
IIIDlabels,
]
\def\A{(5,0,0)}
\def\B{(5,5,0)}
\def\C{(0,5,0)}
\def\D{(0,0,0)}
\def\E{(5,0,5)}
\def\F{(5,5,5)}
\def\G{(0,5,5)}
\def\H{(0,0,5)}
\foreach \i in {A,B,...,H}{\expandafter\pstThreeDDot\csname\i\endcsname}
\expandafter\pstThreeDBox\D\A\C\H
\end{pspicture}
\end{document}
答案1
\documentclass[pstricks,border=1cm,12pt]{standalone}
\usepackage{pst-3dplot}
\psset
{
Alpha=30,
Beta=30,
}
\begin{document}
\begin{pspicture}[showgrid=true](-5,-5)(10,10)
\pstThreeDCoor
[
xMin=-1,
xMax=5,
yMin=-1,
yMax=5,
zMin=-1,
zMax=5,
IIIDticks,
IIIDticksize=.1,
IIIDlabels,
]
\def\A{(5,0,0)}
\def\B{(5,5,0)}
\def\C{(0,5,0)}
\def\D{(0,0,0)}
\def\E{(5,0,5)}
\def\F{(5,5,5)}
\def\G{(0,5,5)}
\def\H{(0,0,5)}
\foreach \i in {A,B,...,H}{\edef\coor{\csname\i\endcsname}\expandafter\pstThreeDDot\coor}
\edef\coor{\D\A\C\H}
\expandafter\pstThreeDBox\coor
\end{pspicture}
\end{document}
答案2
这可能有点过度,但你可以考虑不同的应用。
\documentclass[pstricks,border=1cm,12pt]{standalone}
\usepackage{pst-3dplot}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\coords}{m}
{
\prop_set_from_keyval:Nn \l_tmpa_prop { #1 }
}
\NewDocumentCommand{\mapcoords}{m}
{
\prop_map_inline:Nn \l_tmpa_prop { #1##2 }
}
\NewExpandableDocumentCommand{\usecoords}{mm}
{
\use:x { \exp_not:N #1 \tl_map_function:nN { #2 } \__mop_item:n }
}
\cs_new:Nn \__mop_item:n { \prop_item:Nn \l_tmpa_prop { #1 } }
\ExplSyntaxOff
\psset{
Alpha=30,
Beta=30,
}
\begin{document}
\begin{pspicture}[showgrid=true](-5,-5)(10,10)
\pstThreeDCoor[
xMin=-1,
xMax=5,
yMin=-1,
yMax=5,
zMin=-1,
zMax=5,
IIIDticks,
IIIDticksize=.1,
IIIDlabels,
]
\coords{
A={(5,0,0)},
B={(5,5,0)},
C={(0,5,0)},
D={(0,0,0)},
E={(5,0,5)},
F={(5,5,5)},
G={(0,5,5)},
H={(0,0,5)}
}
\mapcoords{\pstThreeDDot}
\usecoords{\pstThreeDBox}{DACH}
\end{pspicture}
\end{document}
使用时,\coords
我将坐标存储在属性列表中;\mapcoords
通过将所有坐标提供给作为参数给出的宏来使用它们。使用 时,\usecoords
您可以使用任意数量的名称(不由单个字母组成的名称应该用括号括起来),将相应的坐标提供给作为第一个参数给出的宏。