我正在尝试绘制一个不连续的字段,如附图所示,但我不知道如何使用 Tikz 来实现。有什么想法吗?
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[dashed,very thick] (-1.0,4.0) -- ++(0,-4) -- ++(2,0) -- ++(0,4);
\begin{scope}
\clip (-1.0,0.0) rectangle (1.0,0.5);
\foreach \y in {0.0,0.1,...,0.5}{
\foreach \x in {-1.0,-0.9,...,1.0}{
\pgfmathsetmacro\y{ 0.1*cos( rand r ) + \y };
\pgfmathsetmacro\x{ 0.1*cos( rand r ) + \x };
\fill[gray] (\x,\y) circle[ radius=1pt ];
}
}
\end{scope}
\draw[very thick] (-1.0,0.0) rectangle (1.0,0.5);
\draw[{latex}-{latex}](-1.01,0.6) -- (0.99,0.6) node[midway, above]{$d$};
\draw[|<->|](4.2,0)--(4.2,-1.)node[midway,right]{$\lambda$};
% fields
\foreach \y in {-1.0,-0.,...,3}{
\draw[](-4,\y) -- (4,\y);
\foreach \x in {-3,-2,-0.5,0.5,2,3}{
\draw[-{latex}, thick](\x,\y) -- ++(0,0.4);
}
}
\end{tikzpicture}
\end{document}
答案1
像这样吗?
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[dashed,very thick] (-1,4) -- ++(0,-4) -- ++(2,0) -- ++(0,4);
\begin{scope}
\clip (-1,0) rectangle (1,0.5);
\foreach \y in {0.0,0.1,...,0.5}{
\foreach \x in {-1.0,-0.9,...,1.0}{
\pgfmathsetmacro\y{ 0.1*cos( rand r ) + \y };
\pgfmathsetmacro\x{ 0.1*cos( rand r ) + \x };
\fill[gray] (\x,\y) circle[ radius=1pt ];
}
}
\end{scope}
\draw[very thick] (-1,0) rectangle (1,0.5);
\draw[{latex}-{latex}](-1.01,0.6) -- (0.99,0.6) node[midway, above]{$d$};
\draw[|<->|](4.2,0)--(4.2,-1.)node[midway,right]{$\lambda$};
% fields
\foreach \y in {-1,...,3}{
\ifnum\y>0
\draw (-4,\y) -- (-.5,\y) -- ++({.125*\y},{-.125*\y}) coordinate [midway] (al\y) ++({1-(.25*\y)},0) -- ++({.125*\y},{.125*\y}) coordinate [midway] (ar\y) -- (4,\y);
\draw [-latex, thick] (al\y) -- ++(45:.4);
\draw [-latex, thick] (ar\y) -- ++(135:.4);
\else
\draw[](-4,\y) -- (4,\y);
\foreach \x in {-0.5,0.5} \draw[-{latex}, thick](\x,\y) -- ++(0,0.4);
\fi
\foreach \x in {-3,-2,2,3}{
\draw[-{latex}, thick](\x,\y) -- ++(0,0.4);
}
}
\end{tikzpicture}
\end{document}