如何使用 tikz 绘制从半圆边界开始的线?

如何使用 tikz 绘制从半圆边界开始的线?

我想使用 绘制下图左侧的图表tikz。到目前为止,我已经能够使用下面给出的代码绘制右侧的图表。我想要做的是切出该图的下半部分,并在下半部分构造一个半圆,使曲线从半圆的边界开始。

随着这一重大变化,我希望这些曲线上的箭头加粗,半圆上的这些线的起点用十字标记。谢谢。在此处输入图片描述

\documentclass[convert]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{calc}
\usetikzlibrary{arrows,decorations.markings}

\begin{document}
\begin{tikzpicture}
\node (I)    at ( 4,0)   {};
\node (II)   at (-4,0)   {};
\node (III)  at (0, 2.5) {};
\node (IV)   at (0,-2.5) {};

\path  
 (II) +(90:4)  coordinate[label=90:]  (IItop)
   +(-90:4) coordinate[label=-90:] (IIbot)
   +(0:4)   coordinate                  (IIright)
   +(180:4) coordinate[label=180:] (IIleft);

\draw (IItop) --
      node[midway, below] {}
  (IIright) -- 
  (IIbot);

\draw   
 (IItop) -- (IIbot);

\path 
  (I) +(90:4)  coordinate (Itop)
   +(-90:4) coordinate (Ibot)
   +(180:4) coordinate (Ileft)
   +(0:4)   coordinate (Iright)
   ;

\draw  (Ileft) -- node[midway, below] {}(Itop) -- (Ibot) -- (Ileft) -- cycle;


\draw[decorate,decoration=zigzag, red, thick] (IItop) -- (Itop)
  node[midway, above, inner sep=2mm] {};

\draw[decorate,decoration=zigzag, red, thick] (IIbot) -- (Ibot)
  node[midway, below, inner sep=2mm] {};

\draw[blue, thick]   
($(Itop)!.5!(Ileft)$) to[out=210, in=-30, looseness=1.3] ($(IItop)!.5!(IIright)$);
\draw[violet, thick]   
($(Itop)!.3!(Ileft)$) to[out=210, in=-30, looseness=1.3] ($(IItop)!.3!(IIright)$);


\draw[->][magenta] 
($(Ibot)!.63!(IIbot)$) to[out=150, in=250, looseness=1.1] ($(Itop)!.60!(IItop)$);



    \draw[->][orange]   
 ($(Ibot)!.63!(IIbot)$) to[out=110, in=210, looseness=1.05] ($(Itop)!.65!(IItop)$);
 \draw[fill] ($(Itop)!.5!(Ileft)$) circle [radius=0.05];

\draw[fill] ($(IItop)!.5!(IIright)$) circle [radius=0.05];

\draw[fill] ($(Itop)!.3!(Ileft)$) circle [radius=0.05];

\draw[fill] ($(IItop)!.3!(IIright)$) circle [radius=0.05];


\end{tikzpicture}  
\end{document}

答案1

这是一项建议。请注意,您的大部分代码都是不需要的,例如空节点。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,bending,calc,decorations.markings,decorations.pathmorphing,shapes.misc}
\tikzset{% 
    ->-/.style={
    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,
     },
     ->-/.default=0.5,
     arc arrow/.cd,length/.initial=2.5mm,
}

\begin{document}
\begin{tikzpicture}[>={Stealth[bend]},
    dot/.style={circle,fill=black,inner sep=0pt,minimum size=3pt},
    cross/.style={cross out,draw}]
 \draw (4,0) coordinate (r) arc[start angle=0,end angle=-180,radius=4]
  coordinate[pos=0.5,cross] (p1) coordinate[pos=0.6,cross] (p2)  coordinate[pos=1] (r) -- 
  (-4,4) coordinate (tl) -- (0,0) coordinate (O) -- (4,4) coordinate (tr) --
  cycle;
 \draw[decorate,decoration=zigzag, red, thick] (tl) -- (tr);
 \draw[blue, thick]   
 ($(tr)!.5!(O)$) coordinate[dot] to[out=210, in=-30, looseness=1.3] ($(tl)!.5!(O)$)
 coordinate[dot];
 \draw[violet, thick]   
 ($(tr)!.3!(O)$) coordinate[dot]  
 to[out=210, in=-30, looseness=1.3] ($(tl)!.3!(O)$) coordinate[dot];

 \draw[->-,magenta] (p1) to[out=150, in=250, looseness=1.1] ($(tr)!.60!(tl)$);
 \draw[->-,orange]  (p2)  to[out=110, in=240, looseness=1.05]  ($(tr)!.65!(tl)$);
\end{tikzpicture}  
\end{document}

在此处输入图片描述

交叉节点的位置分别由pos=0.5和控制pos=0.6

 coordinate[pos=0.5,cross] (p1) coordinate[pos=0.6,cross] (p2)

相关内容