![三维八面体+四面体空间填充镶嵌](https://linux22.com/image/408333/%E4%B8%89%E7%BB%B4%E5%85%AB%E9%9D%A2%E4%BD%93%2B%E5%9B%9B%E9%9D%A2%E4%BD%93%E7%A9%BA%E9%97%B4%E5%A1%AB%E5%85%85%E9%95%B6%E5%B5%8C.png)
答案1
这是适用于视图参数的代码,与此处使用的代码没有太大区别。如果您想创建一个可以调整视图参数的版本,您需要以某种方式使 Ti钾Z 根据平面的三维位置对它们进行排序。这可以通过这个答案回答你之前提出的问题。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{80}{200}
\begin{tikzpicture}[tdplot_main_coords,line cap=round,line join=round,
pics/octahedron/.style={code={
\draw[fill=red!80!black] (-1,0,1) -- (1,0,1) -- (0,{sqrt(2)},0) -- cycle;
\draw[fill=red!30!black] (1,0,1) -- (1,0,-1) -- (0,{sqrt(2)},0) -- cycle;
\draw[fill=red!60!black] (1,0,-1) -- (-1,0,-1) -- (0,{sqrt(2)},0) -- cycle;
\draw[fill=red] (-1,0,-1) -- (-1,0,1) -- (0,{sqrt(2)},0) -- cycle;}},
pics/tetrahedron1/.style={code={
\draw[fill=yellow!60!black] (0,0,-1) -- (1,{sqrt(2)},0) -- (-1,{sqrt(2)},0) -- cycle;
\draw[fill=yellow] (0,0,1) -- (1,{sqrt(2)},0) -- (-1,{sqrt(2)},0) -- cycle;
}},
pics/tetrahedron2/.style={code={
\draw[fill=yellow!60!black] (0,{sqrt(2)},-2) -- (0,{sqrt(2)},0) --
(1,0,-1) -- cycle;
\draw[fill=yellow] (-1,0,-1)-- (0,{sqrt(2)},-2) -- (0,{sqrt(2)},0) -- cycle;;
}}]
\path foreach \Y in {0,1}{ foreach \X in {0,1,2} {
(2*\X+\Y,{sqrt(2)*\Y},-\Y)pic{octahedron}}
foreach \X in {0,...,\the\numexpr2-\Y} { (2*\X+1+\Y,{sqrt(2)*\Y},-\Y) pic{tetrahedron1}}
foreach \X in {0,1,2} { (2*\X+\Y,{sqrt(2)*\Y},-\Y) pic{tetrahedron2}}
};
\path foreach \Y in {2} { foreach \X in {0,1} {
(2*\X+\Y,{sqrt(2)*\Y},-\Y)pic{octahedron}}
foreach \X in {0} {
(2*\X+1+\Y,{sqrt(2)*\Y},-\Y) pic{tetrahedron1}} };
\end{tikzpicture}
\end{document}
我们可以用动画来说明镶嵌的意义。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{80}{200}
\foreach \Iteration in {1,...,21}
{\begin{tikzpicture}[tdplot_main_coords,line cap=round,line join=round,
pics/octahedron/.style={code={
\draw[fill=red!80!black] (-1,0,1) -- (1,0,1) -- (0,{sqrt(2)},0) -- cycle;
\draw[fill=red!30!black] (1,0,1) -- (1,0,-1) -- (0,{sqrt(2)},0) -- cycle;
\draw[fill=red!60!black] (1,0,-1) -- (-1,0,-1) -- (0,{sqrt(2)},0) -- cycle;
\draw[fill=red] (-1,0,-1) -- (-1,0,1) -- (0,{sqrt(2)},0) -- cycle;}},
pics/tetrahedron1/.style={code={
\draw[fill=yellow!60!black] (0,0,-1) -- (1,{sqrt(2)},0) -- (-1,{sqrt(2)},0) -- cycle;
\draw[fill=yellow] (0,0,1) -- (1,{sqrt(2)},0) -- (-1,{sqrt(2)},0) -- cycle;
}},
pics/tetrahedron2/.style={code={
\draw[fill=yellow!60!black] (0,{sqrt(2)},-2) -- (0,{sqrt(2)},0) --
(1,0,-1) -- cycle;
\draw[fill=yellow] (-1,0,-1)-- (0,{sqrt(2)},-2) -- (0,{sqrt(2)},0) -- cycle;;
}}]
\path[tdplot_screen_coords] (-6.5,-3.5) rectangle (1,1.5);
\path foreach \Y in {0,1}{ foreach \X in {0,1,2} {
\ifnum\the\numexpr\X+9*\Y<\Iteration
(2*\X+\Y,{sqrt(2)*\Y},-\Y)pic{octahedron}
\fi
}
foreach \X in {0,...,\the\numexpr2-\Y} {
\ifnum\the\numexpr\X+9*\Y+3<\Iteration
(2*\X+1+\Y,{sqrt(2)*\Y},-\Y) pic{tetrahedron1}
\fi
}
foreach \X in {0,1,2} {
\ifnum\the\numexpr\X+9*\Y+6<\Iteration
(2*\X+\Y,{sqrt(2)*\Y},-\Y) pic{tetrahedron2}
\fi }
};
\path foreach \Y in {2} { foreach \X in {0,1} {
\ifnum\the\numexpr\X+18<\Iteration
(2*\X+\Y,{sqrt(2)*\Y},-\Y)pic{octahedron}
\fi}
foreach \X in {0} {
\ifnum20<\Iteration
(2*\X+1+\Y,{sqrt(2)*\Y},-\Y) pic{tetrahedron1}
\fi} };
\end{tikzpicture}}
\end{document}