3

I have the following code:

\begin {tikzpicture}[-latex ,auto ,node distance =0.8cm and 0.8cm ,on grid,
thin , state/.style ={ circle ,top color = black, bottom color = black,
draw,black , text=black, minimum width =0.01 cm}]
\node[state] (a1) {};
\node[state] (b1) [below =of a1]{};
\node[state] (c1) [right =of a1]{};
\node[state] (d1) [below =of c1]{};
\node[shape=circle, draw=black, minimum size = 4cm, fit={(a1)(d1)}]{};
\node[state] (a2) [right=7cm of a1] {};
\node[state] (b2) [right =of a2] {};
\node[state] (c2) [below =of a2] {};
\node[state] (d2) [right =of c2] {};
\node[state] (d3) [above =3cm of d2] {};
\node[state] (d4) [right =2cm of d2] {};
\node[state] (d5) [below =2cm of d2] {};
\node[state] (d6) [above = of d4] {};
\node[state] (d6) [above = of d6] {};
\node[shape=circle,
      draw=black,
      minimum size=3cm,
      fit={(a2)(d2)}]{};
\node[shape=circle, draw=black, fit={(d2)(d3)(d4)(d5)}]{};
\path (b1) edge [bend right=0] node[] {} (a2);
\end{tikzpicture} \newline \newline

This produces:

enter image description here

I'd like to draw a lines as shown below:

enter image description here

Stuart
  • 133
  • 3
    This answer has an elegant solution to drawing the two tangents in TikZ https://tex.stackexchange.com/a/254055/15036 – Thruston Mar 03 '19 at 17:16
  • 1
    Are you trying to draw a zoomed-in region? If so, try here: http://pgfplots.net/tikz/examples/spy-plot/ or search for Tikz Spy on this site. – Thruston Mar 03 '19 at 17:24

2 Answers2

4

This is a possible solution, but I don't think it is the best way.

Add names for the circles.

\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{positioning,fit}
\begin{document}
\begin {tikzpicture}[,auto ,node distance =0.8cm and 0.8cm ,on grid,
thin , state/.style ={ circle ,top color = black, bottom color = black,
draw,black , text=black, minimum width =0.01 cm}]
\node[state] (a1) {};
\node[state] (b1) [below =of a1]{};
\node[state] (c1) [right =of a1]{};
\node[state] (d1) [below =of c1]{};
\node[shape=circle, draw=black, minimum size = 4cm, fit={(a1)(d1)}] (circle1) {};
\node[state] (a2) [right=7cm of a1] {};
\node[state] (b2) [right =of a2] {};
\node[state] (c2) [below =of a2] {};
\node[state] (d2) [right =of c2] {};
\node[state] (d3) [above =3cm of d2] {};
\node[state] (d4) [right =2cm of d2] {};
\node[state] (d5) [below =2cm of d2] {};
\node[state] (d6) [above = of d4] {};
\node[state] (d6) [above = of d6] {};
\node[shape=circle,
      draw=black,
      minimum size=3cm,
      fit={(a2)(d2)}] (circle2) {};
\node[shape=circle, draw=black, fit={(d2)(d3)(d4)(d5)}]{};
\path[-latex] (b1) edge [bend right=0] node[] {} (a2);
\draw[thick,red] (circle1.north)--(circle2.north);
\draw[thick,red] (circle1.south)--(circle2.south);
\end{tikzpicture}
\end{document} 

enter image description here

  • 2
    I think the OP is looking for tangents on these circles and not to connect their north points... if for example the right circle was smaller this solution would not give a nice result. – koleygr Mar 03 '19 at 17:17
  • @koleygr Indeed from the attached figure we can't say if the OP wants to join the two norths or have a tangent line. I thought of that too, and that is why I said "but I don't think it is the best way". If the OP explains his question further, I will be very glad to delete my answer. –  Mar 03 '19 at 17:18
  • 2
    This is perfect. I just want lines to show that circle on the right is a subset of the circle on the left. Thank you! Will accept asnwer in 2mins when it lets me. – Stuart Mar 03 '19 at 17:20
  • 1
    Wow... I was almost ready to insist that even without a clear question about these tangents it still seems a clear expectation to me... Nice guess (+1) – koleygr Mar 03 '19 at 17:22
4

AFAIK the first way to draw a tangent at two circles has been proposed in this nice answer. However, can't refrain from using this one.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc,positioning,fit}
\begin{document}
\begin{tikzpicture}[tangent of circles/.style args={%
at #1 and #2 with radii #3 and #4}{insert path={%
let \p1=($(#2)-(#1)$),\n1={atan2(\y1,\x1)},\n2={veclen(\y1,\x1)*1pt/1cm},
    \n3={atan2(#4-#3,\n2)}
     in ($(#1)+(\n3+\n1+90:#3)$) -- ($(#2)+(\n3+\n1+90:#4)$)}},-latex ,auto ,node distance =0.8cm and 0.8cm ,on grid,
thin , state/.style ={ circle ,top color = black, bottom color = black,
draw,black , text=black, minimum width =0.01 cm}]
  \node[state] (a1) {};
  \node[state] (b1) [below =of a1]{};
  \node[state] (c1) [right =of a1]{};
  \node[state] (d1) [below =of c1]{};
  \node[shape=circle, draw=black, minimum size = 4cm, fit={(a1)(d1)}]
  (circ1){};
  \node[state] (a2) [right=7cm of a1] {};
  \node[state] (b2) [right =of a2] {};
  \node[state] (c2) [below =of a2] {};
  \node[state] (d2) [right =of c2] {};
  \node[state] (d3) [above =3cm of d2] {};
  \node[state] (d4) [right =2cm of d2] {};
  \node[state] (d5) [below =2cm of d2] {};
  \node[state] (d6) [above = of d4] {};
  \node[state] (d6) [above = of d6] {};
  \node[shape=circle,
        draw=black,
        minimum size=3cm,
        fit={(a2)(d2)}] (circ2){};
  \node[shape=circle, draw=black, fit={(d2)(d3)(d4)(d5)}]{};
  \path (b1) edge [bend right=0] node[] {} (a2);
  \draw[red,-,tangent of circles={at circ1.center and circ2.center with radii 2
  and 1.5}];
  \draw[red,-,tangent of circles={at circ2.center and circ1.center with radii
  1.5 and 2}];
\end{tikzpicture} 
\end{document}

enter image description here