在三维空间中绘制多面体镶嵌

在三维空间中绘制多面体镶嵌

考虑由以下组成的多面体

  • 24 个顶点(4×6)
  • 14 个面(包含 6 个正方形和 8 个六边形)
  • 36 条边(4×6+6×82=36)。

这个多面体可以像这样包装和镶嵌三维空间。

问题:在 LaTex 中,有哪些可用的方法可以绘制此图?(我的尝试是展示这种包装是可能的,并准备了此图 [不使用 LaTex..]。)

在此处输入图片描述

答案1

这绘制了这样的多面体并说明了它们提供了 3d 空间的镶嵌。

  1. 符号 1正确识别多面体为截角八面体。
  2. 可以通过 Mathematica 获取(此类)多面体的数据N[PolyhedronData["TruncatedOctahedron", "GraphicsComplex"]]
  3. 这个答案的主要目的是提供一种使用 Ti 绘制和排序多面体的方法Z。
  4. 这个答案需要实验3dtools 库

在 Mathematica 的惯例中,这些多面体位于具有晶格向量的晶格点上(0,2,-\sqrt{2}), (2,0,-\sqrt{2}), (0,2,\sqrt{2})。可以通过将多面体的轨迹投影到屏幕法线上来获得 3d 排序,并根据投影进行排序。(为了加快编译速度,多面体存储在\saveboxes 中,这是隐含的建议这里

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{backgrounds,3dtools}
\newsavebox\TruncatedOctahedronBlue
\newsavebox\TruncatedOctahedronOrange
\tdplotsetmaincoords{80}{105}
\newcommand{\TruncatedOctahedron}{%
\begin{tikzpicture}[tdplot_main_coords,line cap=round,line join=round]
\path foreach \Coord [count=\X] in 
{(-1.5,-0.5,0.), (-1.5,0.5,0.), (-1.,-1.,-0.707107), (-1.,-1.,0.707107), 
(-1.,1.,-0.707107), (-1.,1.,0.707107), (-0.5,-1.5,0.), (-0.5, -0.5,-1.41421),
(-0.5,-0.5,1.41421), (-0.5,0.5,-1.41421), (-0.5,0.5, 1.41421), (-0.5,1.5,0.),
(0.5,-1.5,0.), (0.5,-0.5,-1.41421), (0.5,-0.5, 1.41421), (0.5,0.5,-1.41421),
(0.5,0.5,1.41421), (0.5,1.5,0.), (1.,-1., -0.707107), (1.,-1.,0.707107),
(1.,1.,-0.707107), (1.,1.,0.707107), (1.5, -0.5,0.), (1.5,0.5,0.)}
  {\Coord coordinate (p\X) \pgfextra{\xdef\NumVertices{\X}}};
 %\message{number of vertices is \NumVertices^^J} 
 % normal of screen 
 \path[overlay] ({sin(\tdplotmaintheta)*sin(\tdplotmainphi)},
    {-1*sin(\tdplotmaintheta)*cos(\tdplotmainphi)},
    {cos(\tdplotmaintheta)}) coordinate (n)
    (0.5,0.5,{0.5*sqrt(2)})  coordinate (L); 
 \edef\lstPast{0}
 \foreach \poly in 
 {{17,11,9,15}, {14,8,10,16}, {22,24,21,18}, {12,5,2,6}, {13,19,23,20},
    {4,1,3,7}, {19,13,7,3, 8,14}, {15,9,4,7,13,20}, {16,10,5,12,18,21}, 
    {22,18,12,6,11,17}, {20,23,24,22,17,15}, {14,16,21,24,23, 19}, {9,11,6,2,1,4},  
    {3,1,2,5,10,8}}
 {
  \pgfmathtruncatemacro{\ione}{{\poly}[0]}
  \pgfmathtruncatemacro{\itwo}{{\poly}[1]}
  \pgfmathtruncatemacro{\ithree}{{\poly}[2]}
  \path[overlay,3d coordinate={(dA)=(p\itwo)-(p\ione)},
   3d coordinate={(dB)=(p\itwo)-(p\ithree)},
   3d coordinate={(nA)=(dA)x(dB)}] ;
  \pgfmathtruncatemacro{\jtest}{sign(TD("(nA)o(p\ione)"))}
  % make sure that the normal points outwards
  \ifnum\jtest<0
   \path[overlay,3d coordinate={(nA)=(dB)x(dA)}];
  \fi
  % compute projection the normal of the polygon on the normal of screen    
  \pgfmathsetmacro\myproj{TD("(nA)o(n)")}
  \pgfmathsetmacro\lproj{TD("(nA)o(L)")}
  \pgfmathtruncatemacro{\itest}{sign(\myproj)}
  \pgfmathtruncatemacro{\cf}{70+20*\lproj}% color fraction between 50 and 90
  \ifnum\itest>-1 
   \draw[ultra thin] [fill=mypolyhedroncolor!\cf]
   plot[samples at=\poly,variable=\x](p\x) -- cycle; 
  \else
   \begin{scope}[on background layer] 
    \draw[gray!20,ultra thin] [fill=mypolyhedroncolor!\cf!black]
    plot[samples at=\poly,variable=\x](p\x) -- cycle;  
   \end{scope}
  \fi
  }  
\end{tikzpicture}}
\colorlet{mypolyhedroncolor}{blue}
\sbox\TruncatedOctahedronBlue{\TruncatedOctahedron}
\colorlet{mypolyhedroncolor}{orange}
\sbox\TruncatedOctahedronOrange{\TruncatedOctahedron}
\begin{document}
\begin{tikzpicture}[tdplot_main_coords,line cap=round,line join=round]
\path foreach \Y in {0,1,2} {foreach \X in {0,1,2} 
  {({2*\Y}, {2*\X}, {-sqrt(2)*\X-sqrt(2)*\Y})
  node{\pgfmathtruncatemacro{\Z}{\X+\Y}
  \ifodd\Z
  \usebox{\TruncatedOctahedronOrange}
  \else
  \usebox{\TruncatedOctahedronBlue}
  \fi} }};
\end{tikzpicture}
\end{document}

在此处输入图片描述

为了说明这是一个镶嵌图案,可能需要逐一绘制它们。

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{backgrounds,3dtools}
\newsavebox\TruncatedOctahedronBlue
\newsavebox\TruncatedOctahedronOrange
\tdplotsetmaincoords{80}{105}
\newcommand{\TruncatedOctahedron}{%
\begin{tikzpicture}[tdplot_main_coords,line cap=round,line join=round]
\path foreach \Coord [count=\X] in 
{(-1.5,-0.5,0.), (-1.5,0.5,0.), (-1.,-1.,-0.707107), (-1.,-1.,0.707107), 
(-1.,1.,-0.707107), (-1.,1.,0.707107), (-0.5,-1.5,0.), (-0.5, -0.5,-1.41421),
(-0.5,-0.5,1.41421), (-0.5,0.5,-1.41421), (-0.5,0.5, 1.41421), (-0.5,1.5,0.),
(0.5,-1.5,0.), (0.5,-0.5,-1.41421), (0.5,-0.5, 1.41421), (0.5,0.5,-1.41421),
(0.5,0.5,1.41421), (0.5,1.5,0.), (1.,-1., -0.707107), (1.,-1.,0.707107),
(1.,1.,-0.707107), (1.,1.,0.707107), (1.5, -0.5,0.), (1.5,0.5,0.)}
  {\Coord coordinate (p\X) \pgfextra{\xdef\NumVertices{\X}}};
 %\message{number of vertices is \NumVertices^^J} 
 % normal of screen 
 \path[overlay] ({sin(\tdplotmaintheta)*sin(\tdplotmainphi)},
    {-1*sin(\tdplotmaintheta)*cos(\tdplotmainphi)},
    {cos(\tdplotmaintheta)}) coordinate (n)
    (0.5,0.5,{0.5*sqrt(2)})  coordinate (L); 
 \edef\lstPast{0}
 \foreach \poly in 
 {{17,11,9,15}, {14,8,10,16}, {22,24,21,18}, {12,5,2,6}, {13,19,23,20},
    {4,1,3,7}, {19,13,7,3, 8,14}, {15,9,4,7,13,20}, {16,10,5,12,18,21}, 
    {22,18,12,6,11,17}, {20,23,24,22,17,15}, {14,16,21,24,23, 19}, {9,11,6,2,1,4},  
    {3,1,2,5,10,8}}
 {
  \pgfmathtruncatemacro{\ione}{{\poly}[0]}
  \pgfmathtruncatemacro{\itwo}{{\poly}[1]}
  \pgfmathtruncatemacro{\ithree}{{\poly}[2]}
  \path[overlay,3d coordinate={(dA)=(p\itwo)-(p\ione)},
   3d coordinate={(dB)=(p\itwo)-(p\ithree)},
   3d coordinate={(nA)=(dA)x(dB)}] ;
  \pgfmathtruncatemacro{\jtest}{sign(TD("(nA)o(p\ione)"))}
  % make sure that the normal points outwards
  \ifnum\jtest<0
   \path[overlay,3d coordinate={(nA)=(dB)x(dA)}];
  \fi
  % compute projection the normal of the polygon on the normal of screen    
  \pgfmathsetmacro\myproj{TD("(nA)o(n)")}
  \pgfmathsetmacro\lproj{TD("(nA)o(L)")}
  \pgfmathtruncatemacro{\itest}{sign(\myproj)}
  \pgfmathtruncatemacro{\cf}{70+20*\lproj}% color fraction between 50 and 90
  \ifnum\itest>-1 
   \draw[ultra thin] [fill=mypolyhedroncolor!\cf]
   plot[samples at=\poly,variable=\x](p\x) -- cycle; 
  \else
   \begin{scope}[on background layer] 
    \draw[gray,ultra thin] [fill=mypolyhedroncolor!\cf!black]
    plot[samples at=\poly,variable=\x](p\x) -- cycle;  
   \end{scope}
  \fi
  }  
\end{tikzpicture}}
\colorlet{mypolyhedroncolor}{blue}
\sbox\TruncatedOctahedronBlue{\TruncatedOctahedron}
\colorlet{mypolyhedroncolor}{orange}
\sbox\TruncatedOctahedronOrange{\TruncatedOctahedron}
\begin{document}
\foreach \Ani in {1,...,27}
{\begin{tikzpicture}[tdplot_main_coords,line cap=round,line join=round]
\path[tdplot_screen_coords] (-3,-8.2) rectangle (10,4.5);
\path foreach \Y in {0,1,2} {foreach \Z in {0,1,2} 
    {foreach \X in {0,1,2} 
  {({2*\Y}, {2*\X+2*\Z},
  {-sqrt(2)*\X-sqrt(2)*\Y+sqrt(2)*\Z})
  node{\pgfmathtruncatemacro{\QQ}{\X+3*\Z+9*\Y}
  \ifnum\Ani>\QQ
  \ifodd\QQ
  \usebox{\TruncatedOctahedronOrange}
  \else
  \usebox{\TruncatedOctahedronBlue}
  \fi
  \fi} }}};
\end{tikzpicture}}
\end{document}

在此处输入图片描述

相关内容