有人知道如何使用 tikz 制作这些体心立方晶体结构模型吗?

有人知道如何使用 tikz 制作这些体心立方晶体结构模型吗?

它们用于材料科学与工程的研究......Callister 的书中出现的图像模型

在此处输入图片描述

答案1

欢迎来到 TeX:SE!!!

右图

右图比较简单,只需要线条和圆圈(带ball阴影),最重要的是按顺序画,同时考虑到可见性。

\documentclass[tikz,border=1.618mm]{standalone}
\usetikzlibrary{perspective}

\tikzset
{%
  my ball/.style={draw,circle,minimum size=2*\r cm,inner sep=0,shading=ball,ball color=cyan!50!blue,opacity=#1},
  my ball/.default=1,
  hidden line/.style={black!60}
}

\begin{document}
\begin{tikzpicture}[3d view={110}{20},line cap=round]
\def\a{3}
\def\r{0.2}
\node[my ball=0.5] at (0,0,0) {};
\node[my ball=0.5] at (0.5*\a,0.5*\a,0.5*\a) {};
\draw[hidden line] (\r,0,0) -- (\a-\r,0,0);
\draw[hidden line] (0,\r,0) -- (0,\a-\r,0);
\draw[hidden line] (0,0,\r) -- (0,0,\a-\r);
\node[my ball] at (\a,0,0) {};
\node[my ball] at (0,\a,0) {};
\node[my ball] at (0,0,\a) {};
\draw (\a,\r,0) -- (\a,\a-\r,0);
\draw (\a,0,\r) -- (\a,0,\a-\r);
\draw (\r,\a,0) -- (\a-\r,\a,0);
\draw (0,\a,\r) -- (0,\a,\a-\r);
\draw (\r,0,\a) -- (\a-\r,0,\a);
\draw (0,\r,\a) -- (0,\a-\r,\a);
\node[my ball] at (\a,\a,0) {};
\node[my ball] at (\a,0,\a) {};
\node[my ball] at (0,\a,\a) {};
\draw (\a,\a,\r) -- (\a,\a,\a-\r);
\draw (\a,\r,\a) -- (\a,\a-\r,\a);
\draw (\r,\a,\a) -- (\a-\r,\a,\a);
\node[my ball] at (\a,\a,\a) {};
\end{tikzpicture}
\end{document}

在此处输入图片描述

左图

这有点复杂。在这里我会选择一个isometric view(总是让这种图片更容易),我也会使用3d库来通过选项更改平面canvas is...。同样,顺序对于可见性非常重要。最后,几个\foreach循环有助于避免重复代码。

\documentclass[tikz,border=1.618mm]{standalone}
\usetikzlibrary{3d,perspective}

\tikzset
{% styles
   xy/.style={canvas is xy plane at z=\a,shift={(0.5*\a,0.5*\a)},rotate=90*\i,fill=cyan!30},
   xz/.style={canvas is xz plane at y=\a,shift={(0.5*\a,0.5*\a)},rotate=90*\i,fill=cyan!50},
   yz/.style={canvas is yz plane at x=\a,shift={(0.5*\a,0.5*\a)},rotate=90*\i,fill=cyan!70},
   my ball/.style={shading=ball,ball color=blue!50}
}

\begin{document}
\begin{tikzpicture}[isometric view,rotate around z=180,line cap=round,line join=round]
% 
\def\a{3} % edge length
\pgfmathsetmacro\r{0.25*sqrt(3)*\a} % sphere radius
% background
\foreach\i in {0,120,240}
  \draw[rotate=\i,my ball] (\a,0,0) --++ (0,\r,0) arc (90:135:\r) arc (0:60:\r cm)
      {[canvas is xz plane at y=0] arc (135:90:\r)} -- cycle;
% sphere (center)
\draw[my ball]  (0.5*\a,0.5*\a,0.5*\a) circle (\r cm);
% foreground
\foreach\i in {0,120,240}
  \draw[rotate=\i,my ball] (\a,\a,0) --++ (60:\r cm) arc (60:120:\r cm) -- cycle;
% section planes
\foreach\s in {xy,xz,yz} \foreach\i in {1,...,4}
  \draw[\s] (45:{\a*sin(45)}) --++ (180:\r) arc (180:270:\r) -- cycle;
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容