使用 tikz 绘制图片的建议

使用 tikz 绘制图片的建议

在此处输入图片描述

您好,我对 tikz 还很陌生,我想画一些类似的东西,有什么建议吗?

谢谢

答案1

概念上类似于Colo 的回答很棒但使用普通的 TiZ“仅”,并带有椭圆弧和弯曲箭头。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,bending,calc,decorations.markings,intersections}
\tikzset{% 
    attach arrow/.style={thick,
    decoration={
        markings,
         mark=at position 0 with {\pgfextra{%
         \pgfmathsetmacro{\tmpArrowTime}{\pgfkeysvalueof{/tikz/arc arrow/length}/(\pgfdecoratedpathlength)}%
         \xdef\tmpArrowTime{\tmpArrowTime}}},
        mark=at position {#1-3*\tmpArrowTime} with {\coordinate(@1);},
        mark=at position {#1-2*\tmpArrowTime} with {\coordinate(@2);},
        mark=at position {#1-1*\tmpArrowTime} with {\coordinate(@3);},
        mark=at position {#1+\tmpArrowTime/2} with {\coordinate(@4);
        \draw[-{Stealth[length=\pgfkeysvalueof{/tikz/arc arrow/length},bend]}] plot[smooth]
         coordinates {(@1) (@2) (@3) (@4)};},
        },
     postaction=decorate,
     },
     attach arrow/.default=0.5,
     arc arrow/.cd,length/.initial=2mm,
}
\begin{document}
\begin{tikzpicture}[bullet/.style={circle,fill,draw,inner sep=1.5pt,label=#1}]
 \path (0,2) coordinate[bullet={above:$y$}] (y)
 (0,-2) coordinate[bullet={below:$x$}] (x);
 \draw[thick,attach arrow,name path=a] (x) arc(270:90:2) node[midway,left]{$a$};
 \draw[thick,attach arrow,name path=b] (x) to[bend left=40] node[midway,right]{$b$} (y);
 \draw[thick,attach arrow] (x) to[bend right=40] node[midway,right]{$c$} (y);
 \draw[thick,attach arrow] (x) arc(-90:90:2) node[midway,right]{$d$};
 \foreach \X in {1,...,7}
 {\path[overlay,name path=h\X] (-2.2,-2+4*\X/7) -- (0,-2+4*\X/7);
 \draw[name intersections={of=a and h\X,by=il},
     name intersections={of=b and h\X,by=ir},dashed] 
    let \p1=($(ir)-(il)$) in (il) 
    arc[start angle=180,end angle=0,x radius=\x1/2,y radius=\x1/8]; 
 \draw[name intersections={of=a and h\X,by=il},
     name intersections={of=b and h\X,by=ir}] 
    let \p1=($(ir)-(il)$) in (il) 
    arc[start angle=180,end angle=360,x radius=\x1/2,y radius=\x1/8];   }
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

tkz-euclid我通过和找到了解决方案tikz

获得左侧小圆环的思路(我认为这是最困难的部分)是将不同的水平线与左侧的两个圆弧相交。我通过\tkzInterLC返回所需的交点(即\tkzGetPoints{l'}{l})获得了此结果。您必须丢弃其中一个,因为它代表右侧的第二个交点。

水平线位于不同的层次:

\foreach \i in {.6,1.2,1.8}{
\tkzDefPoint(-1,\i){l}
\tkzDefPoint(1,\i){r}
    \tkzInterLC(l,r)(O,A)\tkzGetPoints{l'}{l}
    \tkzInterLC(l,r)(D,x)\tkzGetPoints{r'}{r}
  \draw (l) to[bend right] (r);
 \draw[dashed] (l) to[bend left] (r);
 }

我找不到解决方案,无法用漂亮的箭头标签正确地装饰弧线。因此命令\node[] (arrow) at (A) {$\wedge$};需要改进。

无论如何,你明白了

在此处输入图片描述

\documentclass[11pt,a4paper]{article}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}   

\begin{document}

\begin{tikzpicture}
\tkzDefPoints{0/2/O,-2/2/A,2/2/D,0/4/y,0/0/x}
% main structure without arrows labels
\tkzDrawCircle(O,A)
\tkzDrawArc[color=black](D,y)(x)
\tkzDrawArc[color=black](A,x)(y)
% % nodes to get small rings
\foreach \i in {.6,1.2,1.8}{
\tkzDefPoint(-1,\i){l}
\tkzDefPoint(1,\i){r}
    \tkzInterLC(l,r)(O,A)\tkzGetPoints{l'}{l}
    \tkzInterLC(l,r)(D,x)\tkzGetPoints{r'}{r}
\draw (l) to[bend right] (r);
\draw[dashed] (l) to[bend left] (r);
}
% another loop needs because \tkzInterLC has two results (on the undesidered right side)
\foreach \i in {2.4,3,3.6}{
\tkzDefPoint(-1,\i){l}
\tkzDefPoint(1,\i){r}
    \tkzInterLC(l,r)(O,A)\tkzGetPoints{l'}{l}
    \tkzInterLC(l,r)(D,x)\tkzGetPoints{r'}{r}
\draw (l') to[bend right] (r');
\draw[dashed] (l') to[bend left] (r');
}
% bad but functional way to print the arrows
\node[] (arrow) at (A) {$\wedge$};
\node[] (arrow) at (D) {$\wedge$};
\node[] (arrow) at (-.82,2) {$\wedge$};
\node[] (arrow) at (.82,2) {$\wedge$};
% last labels
\tkzDrawPoints(x,y)
\tkzLabelPoint[left](A){$a$}
\tkzLabelPoint[right](D){$d$}
\tkzLabelPoints[above](y)
\tkzLabelPoints[below](x)
\end{tikzpicture}
\end{document}

相关内容