在六边形网格内绘制三角形网格?

在六边形网格内绘制三角形网格?

我制作了以下网格:

六三

使用以下代码:

\documentclass{standalone}
\usepackage{tikz} 
\usetikzlibrary{shapes}

\begin{document}
    \begin{tikzpicture} 
[hexa/.style= {shape=regular polygon, regular polygon sides=6, minimum size=1cm, draw,anchor=south}, tria/.style= {shape=regular polygon, regular polygon sides=3, minimum size=.25cm, draw,anchor=center},circ/.style= {draw,circle,inner sep=2pt,fill}]

\foreach \j in {0,...,9}{% 
     \ifodd\j 
         \foreach \i in {0,...,9}{\node[hexa] (h\j;\i) at ({\j/2+\j/4},{(\i+1/2)*sin(60)}) {};}
         \foreach \i in {0,...,9}{\node[tria] (h\j;\i) at ({\j/2+\j/4},{(\i+1)*sin(60)}) {};}       
    \else
         \foreach \i in {0,...,9}{\node[hexa] (h\j;\i) at ({\j/2+\j/4},{\i*sin(60)}) {};}
         \foreach \i in {0,...,9}{\node[tria] (h\j;\i) at ({\j/2+\j/4},{(\i+1/2)*sin(60)}) {};} 
    \fi}
    \end{tikzpicture}
\end{document}

我想要做的是将三角形稍微缩小一点,然后在六边形和三角形的每个顶点上绘制一个圆。

但是,这里存在一个问题:每个奇数行和偶数行以及每个列的节点都必须是独立的。

基本上,我应该能够为所有奇数列、奇数行、偶数行或偶数列添加 +1。此外,连接到三角形的节点和连接到六边形的节点应该是分开的,可以说存在于不同的“平面”上。

如何实现这一目标?

其原因是为了构建 HCP 晶格在 xy 平面上的“投影”。

HCP晶格如下所示: 格 1 格子 3

我的图可以看作是从“向下”看结构的视图。独立性将允许我以图形方式变换晶格,解释我将这个晶格变成简单立方晶格的数学变换。

答案1

形状定义了各种节点。您可以访问这些节点:

\documentclass{standalone}
\usepackage{tikz} 
\usetikzlibrary{shapes}

\begin{document}
\begin{tikzpicture} 
  [  
     hexa/.style={shape=regular polygon, 
                  regular polygon sides=6, 
                  minimum size=1cm, 
                  %draw,
                  anchor=south}, 
     tria/.style={shape=regular polygon, 
                  regular polygon sides=3, 
                  minimum size=.25cm, 
                  %%draw,
                  anchor=center},
     circ/.style={draw,
                  circle,
                  inner sep=2pt,
                  fill}
  ]

\foreach \j in {0,...,9}{% 
     \ifodd\j 
        \foreach \i in {0,...,9}
          {
            \node[hexa] (h\j;\i) at ({\j/2+\j/4},{(\i+1/2)*sin(60)}) {};
            \path 
                  (h\j;\i.corner 1) node[circle,draw,inner sep=0.8pt] (t1) {}
                  (h\j;\i.corner 2) node[circle,draw,inner sep=0.8pt] (t2) {}
                  (h\j;\i.corner 3) node[circle,draw,inner sep=0.8pt] (t3) {}
                  (h\j;\i.corner 4) node[circle,draw,inner sep=0.8pt] (t4) {}
                  (h\j;\i.corner 5) node[circle,draw,inner sep=0.8pt] (t5) {}
                  (h\j;\i.corner 6) node[circle,draw,inner sep=0.8pt] (t6) {};
            \draw (t1) -- (t2) -- (t3) -- (t4) -- (t5) -- (t6) -- (t1);
          }
        \foreach \i in {0,...,9}
          {
            \node[tria] (h\j;\i) at ({\j/2+\j/4},{(\i+1)*sin(60)}) {};
            \path  (h\j;\i.corner 1) node[circle,draw,inner sep=0.8pt] (t1) {}  
                   (h\j;\i.corner 2) node[circle,draw,inner sep=0.8pt] (t2) {} 
                   (h\j;\i.corner 3) node[circle,draw,inner sep=0.8pt] (t3) {};
             \draw (t1) -- (t2) -- (t3) -- (t1);
          }       
    \else
        \foreach \i in {0,...,9}
          {
            \node[hexa] (h\j;\i) at ({\j/2+\j/4},{\i*sin(60)}) {};
            \path 
                  (h\j;\i.corner 1) node[circle,draw,inner sep=0.8pt] (t1) {}
                  (h\j;\i.corner 2) node[circle,draw,inner sep=0.8pt] (t2) {}
                  (h\j;\i.corner 3) node[circle,draw,inner sep=0.8pt] (t3) {}
                  (h\j;\i.corner 4) node[circle,draw,inner sep=0.8pt] (t4) {}
                  (h\j;\i.corner 5) node[circle,draw,inner sep=0.8pt] (t5) {}
                  (h\j;\i.corner 6) node[circle,draw,inner sep=0.8pt] (t6) {};
            \draw (t1) -- (t2) -- (t3) -- (t4) -- (t5) -- (t6) -- (t1);

          }
        \foreach \i in {0,...,9}
          {
            \node[tria] (h\j;\i) at ({\j/2+\j/4},{(\i+1/2)*sin(60)}) {};
            \path  (h\j;\i.corner 1) node[circle,draw,inner sep=0.8pt] (t1) {}  
                   (h\j;\i.corner 2) node[circle,draw,inner sep=0.8pt] (t2) {} 
                   (h\j;\i.corner 3) node[circle,draw,inner sep=0.8pt] (t3) {};
             \draw (t1) -- (t2) -- (t3) -- (t1);
          } 
    \fi}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

我的方法有两个问题。

  1. 我必须为圆圈创建更多节点。看来一定有办法解决这个问题。
  2. 我似乎不能\draw (t1) -- (t2) -- (t3) -- cycle;正确地书写和理解它cycle

笔记

我的网络连接或防火墙似乎有问题,导致图片无法正确导入。当我换了一台新电脑后,我会尝试编辑图片。

相关内容