三维八面体+四面体空间填充镶嵌

三维八面体+四面体空间填充镶嵌

这被称为三维中的准正则空间填充镶嵌:

形成于

有没有什么聪明的方法可以用 LaTex 绘制这样的图形?

在此处输入图片描述

答案1

这是适用于视图参数的代码,与此处使用的代码没有太大区别。如果您想创建一个可以调整视图参数的版本,您需要以某种方式使 TiZ 根据平面的三维位置对它们进行排序。这可以通过这个答案回答你之前提出的问题。

\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}

在此处输入图片描述

相关内容