Drawing a convex hull of disks

You can define a style, which makes it nearly as easy to draw circles with nodes as with \draw. Then the tangent cs can be used as shown in percusses link.

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
    \begin{tikzpicture}[scale=0.2]
    \tikzset{onlycircle/.style={draw,circle,inner sep=0pt,outer sep=0pt,minimum width=2*#1,transform shape}}
        \node[onlycircle=2cm]   (A) at (-4, 2) {};
        \node[onlycircle=7cm]   (B) at ( 2, 0) {};
        \node[onlycircle=4cm]   (C) at ( 0, 6) {};
        \node[onlycircle=2cm]   (D) at ( 8, 2) {};
        \node[onlycircle=8cm]   (E) at ( 8,-6) {};
        \node[onlycircle=6.1cm] (F) at ( 4,-4) {};

        \draw[red] (tangent cs:node=A,point={(C.north west)}) -- (tangent cs:node=C,point={(A.north west)},solution=2);
        \draw[red] (tangent cs:node=C,point={(D.north east)}) -- (tangent cs:node=D,point={(C.north east)},solution=2);
        \draw[red] (tangent cs:node=D,point={(E.north east)}) -- (tangent cs:node=E,point={(D.north east)},solution=2);
        \draw[red] (tangent cs:node=E,point={(F.south west)}) -- (tangent cs:node=F,point={(E.south west)},solution=2);
        \draw[red] (tangent cs:node=F,point={(B.south west)}) -- (tangent cs:node=B,point={(F.south west)},solution=2);
        \draw[red] (tangent cs:node=B,point={(A.south west)}) -- (tangent cs:node=A,point={(B.south west)},solution=2);
    \end{tikzpicture}
\end{document}

enter image description here


Just for completeness. Since there were two answers in @percusse's link, I was curious how they compare. The bottom-line is that @percusse's solution is an almost perfect approximation. Paul Gaborit's solution seems to be the exact one. In what follows, I add a macro to @Mike's answer that uses Paul Gaborit's answer.

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
% #1: options, #2: circle node 1, #3: circle node 2
\newcommand{\DrawGaboritTangent}[4][]{
  \path let \p1=($(#2.center)-(#2.west)$), \p2=($(#3.center)-(#3.west)$) in
  \pgfextra{\pgfmathsetmacro{\radiusA}{\x1/veclen(\x1,\x2)}
  \pgfmathsetmacro{\radiusB}{\x2/veclen(\x1,\x2)}}
  \ifdim\radiusA pt>\radiusB pt
  coordinate (GaboritC) at (barycentric cs:#2=-\radiusB,#3=\radiusA)
  \else
  coordinate (GaboritC) at (barycentric cs:#2=\radiusB,#3=-\radiusA);
  \fi
  ;
  \draw[#1] (tangent cs:node=#2,point={(GaboritC)},solution=#4) -- 
  (tangent cs:node=#3,point={(GaboritC)},solution=#4);
}
\begin{document}
    \begin{tikzpicture}[scale=0.2]
    \tikzset{onlycircle/.style={draw,circle,inner sep=0pt,outer sep=0pt,minimum width=2*#1,transform shape}}
        \node[onlycircle=2cm]   (A) at (-4, 2) {};
        \node[onlycircle=7cm]   (B) at ( 2, 0) {};
        \node[onlycircle=4cm]   (C) at ( 0, 6) {};
        \node[onlycircle=2cm]   (D) at ( 8, 2) {};
        \node[onlycircle=8cm]   (E) at ( 8,-6) {};
        \node[onlycircle=6.1cm] (F) at ( 4,-4) {};
        \draw[red] (tangent cs:node=A,point={(C.north west)}) -- (tangent cs:node=C,point={(A.north west)},solution=2);
        \DrawGaboritTangent[blue,opacity=0.5]{A}{C}{2}
        \draw[red,opacity=0.5] (tangent cs:node=C,point={(D.north east)}) -- (tangent cs:node=D,point={(C.north east)},solution=2);
        \DrawGaboritTangent[blue,opacity=0.5]{C}{D}{1}
        \draw[red,opacity=0.5] (tangent cs:node=D,point={(E.north east)}) -- (tangent cs:node=E,point={(D.north east)},solution=2);
        \DrawGaboritTangent[blue,opacity=0.5]{D}{E}{2}
        \draw[red,opacity=0.5] (tangent cs:node=E,point={(F.south west)}) -- (tangent cs:node=F,point={(E.south west)},solution=2);
        \DrawGaboritTangent[blue,opacity=0.5]{E}{F}{1}
        \draw[red,opacity=0.5] (tangent cs:node=F,point={(B.south west)}) -- (tangent cs:node=B,point={(F.south west)},solution=2);
        \DrawGaboritTangent[blue,opacity=0.5]{F}{B}{2}
        \draw[red,opacity=0.5] (tangent cs:node=B,point={(A.south west)}) -- (tangent cs:node=A,point={(B.south west)},solution=2);
        \DrawGaboritTangent[blue,opacity=0.5]{A}{B}{1}
    \end{tikzpicture}
\end{document}

enter image description here

The different tangents are hard to distinguish by eye.

Tags:

Tikz Pgf