我想修改黑色曲线,以便包含现在留在外面的红色虚线。围绕原点的圆弧应该围绕复平面下半部分的红点。
\documentclass[8pt,usenames,dvipsnames]{beamer}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.markings}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[scale=0.7, every node/.style={scale=0.85}]
% Configurable parameters
\def\gap{0.2}
\def\bigradius{3}
\def\littleradius{0.25}
% Axes
\draw [help lines,->] (-1.25*\bigradius, 0) -- (1.25*\bigradius,0);
\draw [help lines,->] (0, -1.25*\bigradius) -- (0, 1.25*\bigradius);
% Path
\draw[line width=1pt, decoration={ markings,
mark=at position 0.2455 with {\arrow[line width=0.9pt]{>}},
mark=at position 0.765 with {\arrow[line width=0.9pt]{>}},
mark=at position 0.87 with {\arrow[line width=0.9pt]{>}},
mark=at position 0.97 with {\arrow[line width=0.9pt]{>}}},
postaction={decorate}]
let
\n1 = {asin(\gap/2/\bigradius)},
\n2 = {asin(\gap/2/\littleradius)}
in (\n1:\bigradius) arc (\n1:360-\n1:\bigradius)
-- (-\n2:\littleradius) arc (-\n2:-360+\n2:\littleradius)
-- cycle;
\filldraw [red] (1,0) circle (2pt);
\filldraw [red] (0.5,-1) circle (2pt);
\draw[red, dashed] (1,0) -- (1.25*\bigradius,0);
\draw[red, dashed] (1,0) -- (0.5,-1);
%Labels
\node at (3.6,-0.4){$\Re(z)$};
\node at (-0.6,3.53) {$\Im(z)$};
\end{tikzpicture}
\end{figure}
\end{document}
答案1
欢迎!calc
您正在加载的库允许人们构造与线相距给定距离的点。因此,以下代码中的步骤如下:
- 命名红点。
- 构造与红色虚线段平行但向左或向右移动间隙宽度一半的线段。
- 利用这些辅助线的交点构造路径,并根据对应线段延伸的斜率旋转小弧。
\documentclass[8pt,usenames,dvipsnames]{beamer}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.markings}
\DeclareMathOperator{\re}{Re}
\DeclareMathOperator{\im}{Im}
\begin{document}
\begin{frame}[t]
\frametitle{A contour}
\begin{figure}
\centering
\begin{tikzpicture}[scale=0.7, every node/.style={scale=0.85},
dot/.style={circle,fill,inner sep=1pt}]
% Configurable parameters
\def\gap{0.2cm}
\def\bigradius{3cm}
\def\littleradius{0.25cm}
% Axes
\draw [help lines,->] (-1.25*\bigradius, 0) -- (1.25*\bigradius,0);
\draw [help lines,->] (0, -1.25*\bigradius) -- (0, 1.25*\bigradius);
% red path
\draw[red, dashed] (0.5,-1) node[dot] (c1) {} --(1,0) node[dot] (c2){}
-- (1.25*\bigradius,0) coordinate (c3);
\path let \p1=($(c2)-(c1)$), \n1={atan2(\y1,\x1)} in
($(c1)+(\n1:\gap/2+\littleradius/2)$) coordinate (c1')
($(c1')!\gap/2!90:(c2)$) coordinate (l1)
($(c2)!\gap/2!-90:(c1)$) coordinate (l2)
($(c2)!\gap/2!90:(c3)$) coordinate (l2')
($(c3)!\gap/2!-90:(c2)$) coordinate (l3)
($(c1')!\gap/2!-90:(c2)$) coordinate (r1)
($(c2)!\gap/2!90:(c1)$) coordinate (r2)
($(c2)!\gap/2!-90:(c3)$) coordinate (r2')
($(c3)!\gap/2!90:(c2)$) coordinate (r3);
% Path
\draw[line width=1pt, decoration={ markings,
mark=at position 0.06 with {\arrow[line width=0.9pt]{>}},
mark=at position 0.2455 with {\arrow[line width=0.9pt]{>}},
mark=at position 0.84 with {\arrow[line width=0.9pt]{>}},
mark=at position 0.939 with {\arrow[line width=0.9pt]{>}}
},
postaction={decorate}]
let
\n1 = {asin(\gap/2/\bigradius)},
\n2 = {asin(\gap/2/\littleradius)},
\p1=($(c2)-(c1)$),
\n3={atan2(\y1,\x1)}
in (intersection of l1--l2 and l2'--l3) -- (\n1:\bigradius)
arc[start angle=\n1,end angle=360-\n1,radius=\bigradius]
-- (intersection of r1--r2 and r2'--r3)
-- (r1)
arc[start angle=-\n2+\n3,end angle=-360+\n2+\n3,radius=\littleradius]
-- cycle
;
%Labels
\node at (3.6,-0.4){$\re(z)$};
\node at (-0.6,3.53) {$\im(z)$};
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}
编辑:我调整了箭头的位置。
显然,人们可以使箭头更漂亮,甚至可以弯曲它们,但我不确定你是否想保留当前的箭头。