如何在 TikZ 中绘制狭缝衍射图案?

如何在 TikZ 中绘制狭缝衍射图案?

有人知道如何实施这个方案吗?提前谢谢 衍射图

答案1

这是一个选项(有点臃肿,但您将在下面看到原因)

\documentclass[border = 5pt, tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\def\nframes{20}
\def\frame{0}

\begin{document}

\foreach \frame in {0,...,\nframes}
{
\pgfmathsetmacro{\time}{\frame / \nframes}


\begin{tikzpicture}[
    slit/.style={
      line width = 3pt,
      blue
    },
    wave/.style={
      green!30!black
    },
    arrow/.style={
      ->,
      tips = proper,
      color = magenta,
      line width = 1.5mm
    }
  ]

  %
  \path (-4, -4) rectangle (4, 4);

  % slit
  \draw[slit] (0, 1) -- ++(0, 2) (0, -1) -- ++(0, -2);

  % wave in
  \foreach \x in {-4,...,-1} {
    \draw[wave] (\x + \time, -3) -- (\x + \time, 3);
  }

  % wave out
  \foreach \x in {0,...,3} {
    \draw[wave] (\x + \time, -1) -- (\x + \time, 1);
  }

  \foreach \x in {0,...,2} {
    \draw[wave, xshift = 1cm, yshift = 1cm, rotate = 30] (\x + \time, -1) -- (\x + \time, 1);
    \draw[wave, xshift = 1cm, yshift = -1cm, rotate = -30] (\x + \time, -1) -- (\x + \time, 1);
  }

  % arrow
  \draw[arrow] (0.5, 1) ++ (30:\time) -- ++(30: 1);
  \draw[arrow] (-3.0, 0.0) ++ (0:\time) -- ++(0: 1);
  \draw[arrow] (1.0, 0.0) ++ (0:\time) -- ++(0: 1);
  \draw[arrow] (0.5, -1) ++ (-30:\time) -- ++(-30: 1);

\end{tikzpicture}
}
\end{document}

在此处输入图片描述

现在,如果你取消注释该行,\foreach \frame in {0,...,\nframes}你就会得到以下结果

在此处输入图片描述

相关内容