在 tikz 中绘制多面体的包

在 tikz 中绘制多面体的包

我需要在 TikZ 中绘制一些多面体及其截角版本(PSTRICKS 有,但我更喜欢 PDFLaTeX)。以下是我从网站上修改的八面体代码。对于截角立方体、二十面体、截角二十面体、十二边形和截角十二边形将更具挑战性。您能帮忙按照以下方式绘制这样的多面体吗(使用线条和虚线,没有阴影)?

在此处输入图片描述

\documentclass{article}
\usepackage{pgf,tikz}
\begin{document}
\begin{tikzpicture}[scale=2.3]%
\coordinate (C1) at (0.3,-0.15);
\coordinate (C2) at (0.55,-0.15);
\coordinate (C3) at (0.425,-0.025);
\coordinate (C4) at (0.425,-0.275); 
\coordinate (D1) at (0.85,-0.05); 
\coordinate (D2) at (0.9,0.05); 
\coordinate (D3) at (0.875,0.125);
\coordinate (D4) at (0.875,-0.125); % 
\coordinate (E1) at (0.375,0.375);
\coordinate (E2) at (0.625,0.375);
\coordinate (E3) at (0.525,0.425);
\coordinate (E4) at (0.525,0.325); %
\coordinate (F1) at (0.15,0.015);
\coordinate (F2) at (0.1,-0.015);
\coordinate (F3) at (0.125,0.125);
\coordinate (F4) at (0.125,-0.125); % 
\coordinate (G1) at (0.375,-0.375); 
\coordinate (G2) at (0.625,-0.375);
\coordinate (G3) at (0.475,-0.425);
\coordinate (G4) at (0.575,-0.325);

\begin{scope}[xshift=-2cm, yshift=-.541cm,  scale=.2]
\draw [->] (8.5196,2.38)-- (9.86,2.38);
\draw [color=black] (5.96,4.74)-- (3.86,2.38); 
\draw [color=black] (3.86,2.38)-- (5.34,1.66); 
\draw [color=black] (5.34,1.66)-- (5.96,4.74); 
\draw (5.34,1.66)-- (6.,0.); 
\draw (5.34,1.66)-- (8.08,2.3); 
\draw (3.86,2.38)-- (6.,0.); 
\draw (6.,0.)-- (8.08,2.3); 
\draw (5.96,4.74)-- (8.08,2.3); 
\draw [dash pattern=on 5pt off 5pt] (5.96,4.74)-- (6.38,2.84); 
\draw [dash pattern=on 5pt off 5pt] (6.38,2.84)-- (8.08,2.3); 
\draw [dash pattern=on 5pt off 5pt] (3.86,2.38)-- (6.38,2.84); 
\draw [dash pattern=on 5pt off 5pt] (6.38,2.84)-- (6.,0.);
\end{scope}

\begin{scope}[dashed] 
\draw (C1) -- (C4) -- (C2) -- (C3) -- (C1); 
\draw (D1) -- (D4) -- (D2) -- (D3) -- (D1); 
\draw (E1) -- (E4) -- (E2) -- (E3) -- (E1); 
\draw (F1) -- (F4) -- (F2) -- (F3) -- (F1); 
\draw (G1) -- (G4) -- (G2) -- (G3) -- (G1); 
\end{scope}

\draw (F3) -- (F2) -- (C1) -- (C3) -- (E4) -- (E1); 
\draw (C1) -- (C4) -- (G3) -- (G1) -- (F4) -- (F2); 
\draw (D1) -- (C2) -- (C3) -- (E4) -- (E2) -- (D3) -- (D1); 
\draw (D1) -- (C2) -- (C4) -- (G3) -- (G2) --(D4) -- (D1); 
\draw (E2) -- (E3) -- (E1) -- (F3) -- (F2) -- (F4) -- (G1) -- (G3) --  (G2) -- (D4) -- (D1) -- (D3) -- cycle; 
\end{tikzpicture} 
\end{document}

答案1

至少你可以tikz将 3D 坐标投影到页面上(使用非常简单的透视):只需给出 3 维坐标即可。你还可以通过指定 x、y、z 轴的方向来控制投影。还有一些库定义了其他可能有用的坐标系(极坐标、球坐标等)。

您仍然必须自己绘制所有边缘,但至少如果您知道实际的 3D 坐标,您就不必弄清楚它们应该放在页面上的什么位置。

\documentclass[tikz, border=3pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[z={(-.3cm,-.2cm)}, % direction z gets projected to; can also change x,y
                                       % use cm to specify non-transformed coordinates
                    line join=round, line cap=round % makes the corners look nicer
                   ]
  \draw (0,1,0) -- (-1,0,0) -- (0,-1,0) -- (1,0,0) -- (0,1,0) -- (0,0,1) -- (0,-1,0) (1,0,0) -- (0,0,1) -- (-1,0,0);
  \draw[dashed] (0,1,0) -- (0,0,-1) -- (0,-1,0) (1,0,0) -- (0,0,-1) -- (-1,0,0);
\end{tikzpicture} 
\end{document}

八面体

相关内容