# Automatically generating a bounding “blob” from a set of coordinates

Given a set of coordinates, I want to generate a bounding "blob" of this set.

The closest I have gotten is this (surprisingly simple):

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\node (p1) at (0, 0) {A};
\node (p2) at (1, 1) {B};
\node (p3) at (2, 0.5) {C};
\draw plot [smooth cycle,tension=1] coordinates {(p1) (p2) (p3)};
\end{tikzpicture}
\end{document}


Which produces:

This has two issues:

• The plot goes through the nodes instead of around them. I could use modifiers like .north to fix this to some degree, but that is very tedious.
• I have to specify the boundary coordinates in a proper order to produce the correct result.

How could I use TikZ to compute a bounding blob from a set of unordered coordinates?

There is an extremely easy way to achieve it, if you are willing to specify the order.

\documentclass{standalone}
\usepackage{pgfplots}

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\tikzset{
expand bubble/.style={
preaction={draw,line width=10.4pt},
white,fill,draw,line width=10pt,
},
}

\begin{document}
\begin{tikzpicture}
\node (p1) at (0, 0) {A};
\node (p2) at (1, 1) {B};
\node (p3) at (2, 0.5) {C};
\begin{pgfonlayer}{background}
\path[expand bubble]plot [smooth cycle,tension=1] coordinates {(p1) (p2) (p3)};
\end{pgfonlayer}
\end{tikzpicture}
\end{document}


PS. the same trick is used here

PS2. I personally had not seen the convex hull algorithm implemented in TeX. Can you clarify what you meant by unordered coordinates?

• Unordered coordinates was sort of redundant there, it mostly implied that I did not want to express the order of boundary vertices (if I were to just specify those).I will be using some simple external script to generate a convex hull in response to your observation + this to display the result, thanks! – Tgys Apr 18 '17 at 10:55
• @tgys Nice. Because I was about to suggests a convex hull algorithm: simply draw every triangle! – Symbol 1 Apr 18 '17 at 13:51
• Through TikZ? It sounds like generating a convex hull that way would make the "blob" shape impossible. – Tgys Apr 20 '17 at 11:11