绘制循环:轨迹有方向。如何使用 tikz 绘制以下图形
首先我开始使用代码绘制第二个图
\begin{tikzpicture}
\draw (3,2) ellipse (.5cm and .25cm);
\draw (2.9,1.9) to [controls=+(90:1) and +(90:1)] (3,2);
\end{tikzpicture}
为了绘制最后一个图,我使用了。
\begin{tikzpicture}
\draw (.5,0) .. controls (3,3) and (-1,3) .. (1.5,0);
\end{tikzpicture}
但无法绘制外曲线和内曲线以及箭头。使用 Hobby,我写了
\begin{tikzpicture}[use Hobby shortcut]
\draw (-.3 ,1).. (0, 0) .. ( 1.2 , 0 ) .. ( 0 , 0 ) .. (-.3 ,-1);
\draw (.45, 0) .. ( .9 , 0 ) .. ( .6 , 0 ) .. ( .7 , -0.01);
\draw (-.15, 1.2).. (-.01, .2) ..(.01, .22).. (.6, .1) .. ( 1.3 , 0 ) .. ( 0 , -.1 ) .. (-.3 ,-1.2);
\end{tikzpicture}
但外曲线的问题仍然存在。该怎么办?
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{hobby,decorations.markings}
\begin{document}
\begin{tikzpicture}[
use Hobby shortcut,
vec1/.style={
decorate,
decoration={
markings, % v-- can fine-tune arrow position and rotation
mark=at position 0.1 with {\arrow[rotate=5]{stealth}},
}
},
vec2/.style={
decorate,
decoration={
markings, % v-- here again---fine-tune as needed
mark=at position 0.080 with {\arrow{stealth}},
mark=at position 0.206 with {\arrow{stealth reversed}},
mark=at position 0.800 with {\arrow{stealth reversed}},
mark=at position 0.930 with {\arrow{stealth}},
}
},
]
% filled points
%\fill (0,0) circle (1pt);
%\fill (2,0) circle (1pt);
\draw (0.4, 0) .. (0.8, 0.3) .. (1.0, 0) .. (0.4, 0);
\draw (-.3 ,1).. (0, 0) .. ( 1.2 , 0 )
\draw (-.3 ,-1).. (0, 0) .. ( 1.2 , 0 ) .. ( 0 , 0 ) ;
\draw (.5, 0) .. ( .8 , 0 ) .. ( .6 , 0 ) .. ( .7 , -0.012);
\draw (-.1, 1)..(-.08, .7)..(-.05, .4)..( .1 , .4 )..( .7 , .6 )..( 1.4 , 0 )..( .7 , -.6 )..( .2 , -.4 )..(-.1,-.5)..(-.11 ,-.8);
\end{tikzpicture}
\end{document}
答案1
这是第三张图片的解决方案hobby
。这应该足以让您开始处理另外两张图片。
代码
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{hobby,decorations.markings}
\begin{document}
\begin{tikzpicture}[
use Hobby shortcut,
vec1/.style={
decorate,
decoration={
markings, % v-- can fine-tune arrow position and rotation
mark=at position 0.1 with {\arrow[rotate=5]{stealth}},
}
},
vec2/.style={
decorate,
decoration={
markings, % v-- here again---fine-tune as needed
mark=at position 0.080 with {\arrow{stealth}},
mark=at position 0.206 with {\arrow{stealth reversed}},
mark=at position 0.800 with {\arrow{stealth reversed}},
mark=at position 0.930 with {\arrow{stealth}},
}
},
]
% filled points
\fill (0,0) circle (1pt);
\fill (2,0) circle (1pt);
% inner loop
\draw[postaction=vec1] (-0.6,0.1) .. (0,0.4) .. (0.4,0) ..
(0,-0.4) .. (-0.25,-0.25) .. (-0.1,0.1);
% middle crossing loop
\draw[postaction=vec2] (3,-1) .. (2,0) .. (0,0.93) ..
(-0.93,0) .. (0,-0.93) .. (2,0) .. (3,1);
% outer loop
\draw[-stealth] (2.75,-1) .. (2,-0.75) .. (1.25,-1) .. (0,-1.25) ..
(-1.25,0) .. (0,1.25) .. (1.25,1) .. (2,0.75) .. (2.75,1);
\end{tikzpicture}
\end{document}
输出