# How would I draw, in Tikz, the following diagram of a path of particles through different media?

-

I would draw the path multiple times with different styles and clip it to the rectangles of the current medium so everything outside is removed. This is easier than to calculate the points where the path is crossing the media. However, this might also be an option and can be done with the intersections library.

-

Here is a quick way to draw the dotted points, using decorations for randomizing and dotting (the dotted option doesn't seem to work well with random steps). Play around with the various values to see which yield the best effect.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,decorations.markings}

\begin{document}
\begin{tikzpicture}
\path[
decoration={random steps, segment length=0.4mm,amplitude=0.3mm},
decorate,
postaction={
decoration={
markings,
mark=
between positions 0 and 1 step 1mm
with
{\fill (0,0) circle (0.7pt);}
}
,decorate
}
] (0,0) -- (3,0);
\end{tikzpicture}
\end{document}


-