4

Can someone help me reproduce the following image illustrating arithmetic with integration contours using tikz?

enter image description here


Update 1:

@JMP: I slightly adapted your great solution to produce

enter image description here

where I tried to move the point omega directly onto the circleusing tikz's decorations.markings (as this is actually an important point in the context I intend to use this image). However, I'm having trouble doing this with the second pair of deformed circles. What I'm attempting to achieve is:

enter image description here

Do you know how to do this?


Update 2:

Here's the final code,

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections,decorations.markings}

\begin{document}

\begin{tikzpicture}

    \node [style={circle,minimum width=4cm,fill=gray!20},draw=black,name path=A,decoration={markings,mark=at position 0.175 with {\arrow[ultra thick]{>}}},postaction={decorate}] at (0,0) (A) {};
    \node [style={circle,minimum width=1.2cm},name path=C] at (A.north east) (B) {};
        \filldraw (A) circle (2pt) node [above right] {0} (B) circle (2pt) node [right]{$\omega$};
        \node [above] at (A.north) (annotation) {$z$-contour};
        \draw [thick] (annotation.west) edge[out=180,in=120,->]  ++(-0.4,-0.6);

    \node [style={circle,minimum width=4cm,fill=gray!20},draw=black,name path=C,decoration={markings,mark=at position 0.175 with {\arrow[ultra thick]{>}}},postaction={decorate}] at (6cm,0) (C) {};
    \node [style={circle,minimum width=1.2cm},name path=D] at (C.north east) (D) {};
        \filldraw (C) circle (2pt) node [above right] {0} (D) circle (2pt) node [right]{$\omega$};
        \node [above] at (C.north) (annotation) {$z$-contour};
        \draw [thick] (annotation.west) edge[out=180,in=120,->]  ++(-0.4,-0.6);

    \node [style={circle,minimum width=4cm,fill=gray!20},name path=E] at (12cm,0) (E) {};
    \node [style={circle,minimum width=1.2cm,fill=gray!20},name path=F,decoration={markings,mark=at position 0.15 with {\arrow[ultra thick]{>}}},postaction={decorate}] at (E.north east) (F) {};
        \filldraw (E) circle (2pt) node [above right] {0} (F) circle (2pt) node [right]{$\omega$};

        % intersection points between circles E and F
        \path [name intersections={of = E and F}];
        \coordinate (EF1)  at (intersection-1);
        \coordinate (EF2)  at (intersection-2);

        % calculate angles from center of E/F to intersection points
        \pgfmathanglebetweenpoints{\pgfpointanchor{E}{center}}{\pgfpointanchor{EF1}{center}}
        \let\EEFone\pgfmathresult

        \pgfmathanglebetweenpoints{\pgfpointanchor{E}{center}}{\pgfpointanchor{EF2}{center}}
        \let\EEFtwo\pgfmathresult

        \pgfmathanglebetweenpoints{\pgfpointanchor{F}{center}}{\pgfpointanchor{EF1}{center}}
        \let\FEFone\pgfmathresult

        \pgfmathanglebetweenpoints{\pgfpointanchor{F}{center}}{\pgfpointanchor{EF2}{center}}
        \let\FEFtwo\pgfmathresult

        % draw outline
        \draw[thick]
        (EF2) arc[start angle=\FEFtwo-360, end angle=\FEFone,radius=0.6cm] -- 
        (EF1) arc[start angle=\EEFone-360, end angle=\EEFtwo,radius=2cm];

    \node [style={circle,minimum width=4cm,fill=gray!20},name path=G] at (18cm,0) (G) {};
    \node [style={circle,minimum width=1.2cm,fill=white},name path=H] at (G.north east) (H) {};
        \filldraw (G) circle (2pt) node [above right] {0} (H) circle (2pt) node [right]{$\omega$}; 

        % intersection points between circles G and H
        \path [name intersections={of = G and H}];
        \coordinate (GH1)  at (intersection-1);
        \coordinate (GH2)  at (intersection-2);

        % draw outline 
        \draw[thick,decoration={markings, mark=at position 0.075 with {\arrow[ultra thick]{>}}},postaction={decorate}] 
        (GH2) arc[start angle=\FEFtwo-360, end angle=\FEFone-360,radius=0.6cm] -- 
        (GH1) arc[start angle=\EEFone-360, end angle=\EEFtwo,radius=2cm];

    \node [style={circle,minimum width=4cm}] at (22cm,0) (E) {};
    \node [style={circle,minimum width=1.2cm,draw=black,fill=gray!20},decoration={markings,mark=at position 0.15 with {\arrow[ultra thick]{>}}},postaction={decorate}] at (E.north east) (F) {};
        \filldraw (E) circle (2pt) node [above right] {0} (F) circle (2pt) node [right]{$\omega$};

        {\huge
        \draw (3cm,0) node {$-$} (9cm,0) node {$\to$} (15cm,0) node {$-$} (21cm,0) node {$=$};
        }

\end{tikzpicture}

\end{document}

and its output.

enter image description here

7

Here you go

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}


  \node [style={circle,minimum width=4cm,fill=gray!20},name path=A] at (0,0) (A) {};
  \node [style={circle,minimum width=1.2cm,fill=gray!20},name path=B, above right=-0.3cm] at (A.north east) (B) {};
    \filldraw (A) circle (2pt) node [above right, blue] {0} (B) circle (2pt) node [below]{w};
    \node [above left] at (A.north) (annotation) {z-};
    \node [text=blue,right=-0.7em of annotation.base east, anchor= base west] {contour};
    \draw [thick] (annotation.west) edge[out=180,in=90,->]  ++(-0.5,-0.4);

    % intersection points between circles A and B
    \path [name intersections={of = A and B}];
  \coordinate (AB1)  at (intersection-1);
  \coordinate (AB2)  at (intersection-2);

    % calculate angles from center of A/B to intersection points
    \pgfmathanglebetweenpoints{\pgfpointanchor{A}{center}}{\pgfpointanchor{AB1}{center}}
    \let\AABone\pgfmathresult

    \pgfmathanglebetweenpoints{\pgfpointanchor{A}{center}}{\pgfpointanchor{AB2}{center}}
    \let\AABtwo\pgfmathresult

    \pgfmathanglebetweenpoints{\pgfpointanchor{B}{center}}{\pgfpointanchor{AB1}{center}}
    \let\BABone\pgfmathresult

    \pgfmathanglebetweenpoints{\pgfpointanchor{B}{center}}{\pgfpointanchor{AB2}{center}}
    \let\BABtwo\pgfmathresult

    % draw outline
    \draw[thick]
    (AB1) arc[start angle=\AABone-360, end angle=\AABtwo,radius=2cm] --
    (AB2) arc[start angle=\BABtwo-360, end angle=\BABone,radius=0.6cm];
    \draw[ultra thick, ->] (AB1) arc[start angle=\AABone-360, end angle=\AABone-340,radius=2cm];

  \node [style={circle,minimum width=4cm,fill=gray!20},name path=C] at (7cm,0) (C) {};
  \node [style={circle,minimum width=1.2cm,fill=white},name path=D, above right=-0.3cm] at (C.north east) (D) {};
    \filldraw (C) circle (2pt) node [above right, blue] {0} (D) circle (2pt) node [below]{w}; 

    % intersection points between circles C and D
    \path [name intersections={of = C and D}];
  \coordinate (CD1)  at (intersection-1);
  \coordinate (CD2)  at (intersection-2);

    % draw outline
    \draw[thick]
    (CD1) arc[start angle=\AABone-360, end angle=\AABtwo,radius=2cm] --
    (CD2) arc[start angle=\BABtwo-360, end angle=\BABone-360,radius=0.6cm];
    \draw[ultra thick, ->] (CD1) arc[start angle=\AABone-360, end angle=\AABone-340,radius=2cm];

  \node [style={circle,minimum width=4cm}] at (12cm,0) (E) {};
  \node [style={circle,minimum width=1.2cm,fill=white,draw=black}, above right=-0.3cm] at (E.north east) (F) {};
    \filldraw (E) circle (2pt) node [above right, blue] {0} (F) circle (2pt) node [below]{w};
    \draw[ultra thick, ->] (F) ++(45:0.6cm) arc[start angle=45, end angle=95,radius=0.6cm];

    {\huge
    \draw (3.5cm,0) node {$-$} (10.5cm,0) node {$=$};
    }

\end{tikzpicture}  
\end{document}

enter image description here

  • One more thing. Any chance you could take a look at my updated question? – Casimir Mar 30 '16 at 9:45
  • 1
    Well basically remove the above right=-0.3cm statements within the options, when drawing the small circles – JMP Mar 30 '16 at 10:29
  • Ah, excuse me, I wasn't clear there. What I meant is, I'm trying to move all omegas onto the rims of the undeformed circles. After deformation, omega should still be, where the circle's rim used to be. Wait, let me draw another picture to illustrate. – Casimir Mar 30 '16 at 10:30
  • Alright, the new (third) picture in my question shows what I'm after. – Casimir Mar 30 '16 at 10:42
  • 1
    As stated above, remove above right=-0.3cm in the options of the node, when drawing the small circle. – JMP Mar 30 '16 at 10:47
5

Here is a starting point for your drawings using "clip & draw" method.

\documentclass[tikz]{standalone}

\begin{document}
  \begin{tikzpicture}
    \coordinate (A) at (50:1.2);
    \begin{scope}
      \clip circle(2) [xscale=-1] (A) circle (.4);
      \draw circle(1);
    \end{scope}
    \begin{scope}
      \clip circle(2) [xscale=-1] circle(1);
      \draw  (A) circle (.4);
    \end{scope}
    \fill circle(2pt) (A) circle(2pt);
  \end{tikzpicture}
\end{document}

enter image description here

And if you replace \clip circle(2) [xscale=-1] circle(1); by \clip circle(1); in the second scope you obtain the other contour :

enter image description here

Note: The command \clip circle(2) [xscale=-1] circle(1); clips between the two circles because [xscale=-1] reverse the orientation of the second one.

  • Nice solution, didn't know the \clip command before. – JMP Mar 31 '16 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.