2

I am trying to draw a discontinued field as shown in the attached picture, but I don't know how can i do it using Tikz. Any idea ? enter image description here

\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}
  • Please edit your question and turn your code fragment into something we can compile. – cfr Apr 6 '17 at 1:51
4

Something like this?

broken paths

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.