[Tex/LaTex] Draw a $\epsilon$ neighborhood

diagramstikz-pgf

the image produced by the code above is as followsI would like how to draw a $ \epsilon $ neighborhood of a set with smooth boundary in "tikz".

                \documentclass[tikz, border=5mm]{standalone}
                \usepackage{tikz}
                \usepackage{amsmath}
                \begin{document}

                \begin{tikzpicture}[>=latex]
              \draw plot [smooth cycle, tension=0.6] coordinates {(4.4,0.4) (5,0.2) (5.8,0.6) (6.5773,0.5421)(6.4905,1.1074)  (5.9752,1.2828) (5.4,1.4) (4.6,1) };
               \end{tikzpicture}
              \end{document}

Best Answer

The first thing to realise is that this is impossible. PDF, and therefore TikZ, can only draw cubic bézier lines and enlargening a cubic bézier by the same distance all around can produce something that is not a cubic bézier any more.

So any solution is going to be something of a hack.

Having said that, here's a solution that does produce a path that is a set distance from the original curve. It exploits the fact that when a line is drawn then its thickness obeys exactly the constraint that you are trying to force: that the line is drawn so that at any point on the curve, the width of the line as measured orthogonal to the curve is the given thickness. So if only there were a way to draw only the outer edge of a thick line when drawing the curve ...

That's what this does. To get the edge, we draw the line twice with the second time being white and a little thinner than the first time (as you want it dashed, I decided not to use the double as that can lead to artifacts when viewing the document). To get only the outer edge, we clip against the original curve.

The odd dashing effect is because the dashes are the correct width along the original curve but then scale proportionally through the thickness of the line (taking out the white over-draw shows what's going on there).

\documentclass[tikz, border=5mm]{standalone}
%\url{http://tex.stackexchange.com/q/335826/86}
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}

\begin{tikzpicture}[>=latex]
\begin{scope}[even odd rule]
\clip (3,-1) rectangle (8,3) plot [smooth cycle, tension=0.6] coordinates {(4.4,0.4) (5,0.2) (5.8,0.6) (6.5773,0.5421)(6.4905,1.1074)  (5.9752,1.2828) (5.4,1.4) (4.6,1) };
\draw[line width=1cm,dashed] plot [smooth cycle, tension=0.6] coordinates {(4.4,0.4) (5,0.2) (5.8,0.6) (6.5773,0.5421)(6.4905,1.1074)  (5.9752,1.2828) (5.4,1.4) (4.6,1) };
\draw[line width=.9cm,white] plot [smooth cycle, tension=0.6] coordinates {(4.4,0.4) (5,0.2) (5.8,0.6) (6.5773,0.5421)(6.4905,1.1074)  (5.9752,1.2828) (5.4,1.4) (4.6,1) };
\end{scope}
\draw[line width=.5mm] plot [smooth cycle, tension=0.6] coordinates {(4.4,0.4) (5,0.2) (5.8,0.6) (6.5773,0.5421)(6.4905,1.1074)  (5.9752,1.2828) (5.4,1.4) (4.6,1) };
\end{tikzpicture}
\end{document}

epsilon neighbourhood

Just remember:

If there's something strange,
In your neighbourhood.
Who're you gonna call?
TeX-busters!