答案1
欢迎来到 TeX.SE!!
另外一个,这是一个 3d 解决方案:
\documentclass[tikz,border=1.618mm]{standalone}
\usetikzlibrary{calc,perspective}
\begin{document}
\begin{tikzpicture}[3d view={240}{15},scale=2,line cap=round,line join=round]
% coordinates
\foreach\i in {0,...,5}
\coordinate (A\i) at (60*\i:1);
\foreach\i in {0,1,2}
{
\coordinate (B\i) at ($(120*\i+30:{sqrt(1/3)})+(0,0, {sqrt(2/3)})$);
\coordinate (C\i) at ($(120*\i+90:{sqrt(1/3)})+(0,0,{-sqrt(2/3)})$);
}
% back
\draw[gray] (A4) -- (A5) -- (A0) -- (A1);
\draw[gray] (C0) -- (C2) -- (A0) -- (B0) (C1) -- (C2) -- (A5) -- (B2);
% inner
\draw[orange] (A0) -- (A3) (A1) -- (A4) (A2) -- (A5) (B0) -- (C1) (B1) -- (C2) (B2) -- (C0);
% front
\draw (A1) -- (A2) -- (A3) -- (A4);
\draw (B0) -- (B1) -- (B2) -- cycle;
\draw (A1) -- (B0) (A2) -- (B1) -- (A3) (A4) -- (B2);
\draw (A1) -- (C0) -- (A2) (A3) -- (C1) -- (A4) (C0) -- (C1);
\end{tikzpicture}
\end{document}
或者,如果你改变视图:
\begin{tikzpicture}[3d view={220}{15},...
答案2
实际上,使用极坐标,绘制这个相当简单,至少如果你想保持这样的透视图(这样就不需要任何与 3D 相关的库):
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% outer cooridinates
\coordinate (A) at ([shift={(90:1)}]30:1);
\coordinate (B) at ([shift={(150:1)}]90:1);
\coordinate (C) at ([shift={(210:1)}]150:1);
\coordinate (D) at ([shift={(270:1)}]210:1);
\coordinate (E) at ([shift={(330:1)}]270:1);
\coordinate (F) at ([shift={(30:1)}]330:1);
% inner coordinates
\coordinate (a) at (30:1);
\coordinate (b) at (90:1);
\coordinate (c) at (150:1);
\coordinate (d) at (210:1);
\coordinate (e) at (270:1);
\coordinate (f) at (330:1);
\draw[gray]
(a) -- (c) -- (e) -- cycle
(a) -- (A) -- (B) --
(c) -- (C) -- (D) --
(e) -- (E) -- (F) -- cycle;
\draw[red!50]
(A) -- (D)
(B) -- (E)
(C) -- (F)
(a) -- (d)
(b) -- (e)
(c) -- (f);
\draw
(b) -- (d) -- (f) -- cycle
(b) -- (B) -- (C) --
(d) -- (D) -- (E) --
(f) -- (F) -- (A) -- cycle;
\draw[thick] (A) -- (B) -- (C) -- (D) -- (E) -- (F) -- cycle;
\end{tikzpicture}
\end{document}