我正在尝试绘制一个轮廓积分的区域,我的尝试:
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[trig format=rad]
\usetikzlibrary{angles,quotes}
\draw[->] (-5,0) -- (5,0) node[below]{$\Re$};
\draw[->] (0,-5) -- (0,5) node[left]{$\Im$};
\foreach \x in {}\draw (\x,0.1) -- (\x,-0.1) node[below]{};
\foreach \y in {}\draw (0.1,3*\y) -- (-0.1,3*\y) node[left]{\y};
\draw[red, thick,->] plot[variable=\t,domain=pi/4:2*pi/4,samples=1000,smooth] ({4*cos(\t)},{4*sin(\t)});
\draw[red, thick,->] plot[variable=\t,domain=2*pi/4:3*pi/4,samples=1000,smooth] ({4*cos(\t)},{4*sin(\t)});
\draw[red, thick,->] plot[variable=\t,domain=3*pi/4:4*pi/4,samples=1000,smooth] ({4*cos(\t)},{4*sin(\t)});
\draw[red, thick,->] plot[variable=\t,domain=4*pi/4:5*pi/4,samples=1000,smooth] ({4*cos(\t)},{4*sin(\t)});
\draw[red, thick,->] plot[variable=\t,domain=5*pi/4:6*pi/4,samples=1000,smooth] ({4*cos(\t)},{4*sin(\t)});
\draw[red, thick,->] plot[variable=\t,domain=6*pi/4:7*pi/4,samples=1000,smooth] ({4*cos(\t)},{4*sin(\t)});
\draw[gray, dashed] plot[variable=\t,domain=-pi/4:pi/4,samples=1000,smooth] ({4*cos(\t)},{4*sin(\t)});
\draw[blue, thick,->] (4*0.707,-4*0.707) -- (2.75*0.707,-2.75*0.707);
\draw[blue, thick,->] (2.75*0.707,-2.75*0.707) -- (1.5*0.707,-1.5*0.707);
\draw[gray, dashed] (0,0) -- (1.5*0.707,-1.5*0.707);
\draw[purple, thick,->] plot[variable=\t,domain=7*pi/4:6*pi/4,samples=1000,smooth] ({1.5*cos(\t)},{1.5*sin(\t)});
\draw[purple, thick,->] plot[variable=\t,domain=6*pi/4:5*pi/4,samples=1000,smooth] ({1.5*cos(\t)},{1.5*sin(\t)});
\draw[purple, thick,->] plot[variable=\t,domain=5*pi/4:4*pi/4,samples=1000,smooth] ({1.5*cos(\t)},{1.5*sin(\t)});
\draw[purple, thick,->] plot[variable=\t,domain=4*pi/4:3*pi/4,samples=1000,smooth] ({1.5*cos(\t)},{1.5*sin(\t)});
\draw[purple, thick,->] plot[variable=\t,domain=3*pi/4:2*pi/4,samples=1000,smooth] ({1.5*cos(\t)},{1.5*sin(\t)});
\draw[purple, thick,->] plot[variable=\t,domain=2*pi/4:pi/4,samples=1000,smooth] ({1.5*cos(\t)},{1.5*sin(\t)});
\draw[gray, dashed] plot[variable=\t,domain=-pi/4:pi/4,samples=1000,smooth] ({1.5*cos(\t)},{1.5*sin(\t)});
\draw[green!50!black, thick,->] (2.75*0.707,2.75*0.707) -- (4*0.707,4*0.707);
\draw[green!50!black, thick,->] (1.5*0.707,1.5*0.707) -- (2.75*0.707,2.75*0.707);
\draw[gray, dashed] (0,0) -- (1.5*0.707,1.5*0.707);
\draw [color=black](4.2,0.05) node[below] {$R$};
\draw [color=black](1.7,0.05) node[below] {$\varepsilon$};
\coordinate (a) at (0.18,0.07);
\coordinate (b) at (1,1.6);
\coordinate (c) at (1.8,-0.3);
\draw pic[draw,->,angle radius=0.3cm,"$\delta$" shift={(2.2mm,1mm)}] {angle=c--a--b};
\end{tikzpicture}
\end{document}
输出:
我想更简单地做到这一点。另一方面,我还想将轮廓内的区域涂成灰色,有什么想法可以使代码更短吗?
答案1
不看代码即可重新创建图形:
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{decorations.markings, arrows.meta}
\tikzset{
midarrow/.style={
postaction=decorate,
decoration={markings, mark=at position 0.5 with {\arrow{Latex[scale=0.8]}}},
},
pentaarrow/.style={
postaction=decorate,
decoration={markings, mark=at position 0.17 with {\arrow{Latex[scale=0.8]}}},
decoration={markings, mark=at position 0.33 with {\arrow{Latex[scale=0.8]}}},
decoration={markings, mark=at position 0.50 with {\arrow{Latex[scale=0.8]}}},
decoration={markings, mark=at position 0.67 with {\arrow{Latex[scale=0.8]}}},
decoration={markings, mark=at position 0.83 with {\arrow{Latex[scale=0.8]}}},
},
}
\begin{document}
\begin{tikzpicture}[thick]
\pgfmathsetmacro{\delta}{40}
\pgfmathsetmacro{\r}{1}
\pgfmathsetmacro{\R}{3}
\fill[black!5] (0,0) -- (\delta:\R) arc[radius=\R, start angle=\delta, end angle=-\delta] -- cycle;
\draw[gray, ->] (-4,0) -- (4,0);
\draw[gray, ->] (0,-4) -- (0,4);
\draw[green!60!black, midarrow] (\delta:\r) -- (\delta:\R);
\draw[orange, pentaarrow] (\delta:\R) arc[radius=\R, start angle=\delta, end angle=360-\delta];
\draw[blue, midarrow] (-\delta:\R) -- (-\delta:\r);
\draw[violet, pentaarrow] (-\delta:\r) arc[radius=\r, start angle=-\delta, end angle=-360+\delta];
\draw[gray, dashed, thin] (0,0) -- (\delta:\r) arc[radius=\r, start angle=\delta, end angle=-\delta] --cycle;
\draw[gray, dashed, thin] (\delta:\R) arc[radius=\R, start angle=\delta, end angle=-\delta];
\end{tikzpicture}
\end{document}
编辑:
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{decorations.markings, arrows.meta}
\tikzset{
midarrow/.style={
postaction=decorate,
decoration={markings, mark=at position 0.5 with {\arrow{Latex[scale=0.8]}}},
},
pentaarrow/.style={
postaction=decorate,
decoration={markings, mark=at position 0.17 with {\arrow{Latex[scale=0.8]}}},
decoration={markings, mark=at position 0.33 with {\arrow{Latex[scale=0.8]}}},
decoration={markings, mark=at position 0.50 with {\arrow{Latex[scale=0.8]}}},
decoration={markings, mark=at position 0.67 with {\arrow{Latex[scale=0.8]}}},
decoration={markings, mark=at position 0.83 with {\arrow{Latex[scale=0.8]}}},
},
}
\begin{document}
\begin{tikzpicture}[thick]
\pgfmathsetmacro{\delta}{40}
\pgfmathsetmacro{\r}{1}
\pgfmathsetmacro{\R}{3}
\fill[black!5] (0,0) -- (\delta:\R) arc[radius=\R, start angle=\delta, end angle=-\delta] -- cycle;
\fill[teal!10] (\delta:\r) -- (\delta:\R) arc[radius=\R, start angle=\delta, end angle=360-\delta] -- (-\delta:\r) arc[radius=\r, start angle=-\delta, end angle=-360+\delta] --cycle;
\draw[gray, ->] (-4,0) -- (4,0);
\draw[gray, ->] (0,-4) -- (0,4);
\draw[green!60!black, midarrow] (\delta:\r) -- (\delta:\R);
\draw[orange, pentaarrow] (\delta:\R) arc[radius=\R, start angle=\delta, end angle=360-\delta];
\draw[blue, midarrow] (-\delta:\R) -- (-\delta:\r);
\draw[violet, pentaarrow] (-\delta:\r) arc[radius=\r, start angle=-\delta, end angle=-360+\delta];
\draw[gray, dashed, thin] (0,0) -- (\delta:\r) arc[radius=\r, start angle=\delta, end angle=-\delta] --cycle;
\draw[gray, dashed, thin] (\delta:\R) arc[radius=\R, start angle=\delta, end angle=-\delta];
\end{tikzpicture}
\end{document}