Tikz:连接两个节点的线轨迹

Tikz:连接两个节点的线轨迹

我正在画一条连接两个节点的线。我不明白这条线为什么会奇怪。为什么这条线经过到达点后又回到终点?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[remember picture]  

    \coordinate (A) at (0,0);
    \coordinate (B) at (0,6);
    \coordinate (C) at (3,0);     
    \coordinate (D) at (3,6);
    \coordinate (E) at (5.5,0);         
    \coordinate (F) at (5.5,6);  
    \coordinate (G) at (10,0);          
    \coordinate (H) at (10,6);          

    \draw [name path=A--B] (A) -- (B);
    \draw [name path=B--H] (B) -- (H);
    \draw [name path=H--G] (H) -- (G);
    \draw [name path=C--D] (G) -- (A);
    \draw [dashed,name path=C--D] (C) -- (D); 
    \draw [dashed,name path=E--F] (E) -- (F);

    \path [name path=A--P1] (A) -- (25:10);             
    \draw [name intersections={of=E--F and A--P1, by=P1}];                          
    \node [draw,inner sep=5pt,anchor=east](p1) at (P1)  {};

    \path [name path=A--P2] (A) -- (37:10);
    \draw [name intersections={of=C--D and A--P2, by=P2}] (A) -- (G);                    
    \path [name path=P2--P3] (P2) -- ++(12:10);
    \path [name intersections={of=H--G and P2--P3, by=P3}];  
    \node [draw,anchor=west,inner sep=5pt](p3) at (P3)  {};
    \draw (p1.east) to [out=25,in=12] (p3.west);

\end{tikzpicture} 
\end{document}

在此处输入图片描述

完整代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[remember picture]  

    \coordinate (A) at (0,0);
    \coordinate (B) at (0,6);
    \coordinate (C) at (3,0);     
    \coordinate (D) at (3,6);
    \coordinate (E) at (5.5,0);         
    \coordinate (F) at (5.5,6);  
    \coordinate (G) at (10,0);          
    \coordinate (H) at (10,6);          

    \draw [name path=A--B] (A) -- (B);
    \draw [name path=B--H] (B) -- (H);
    \draw [name path=H--G] (H) -- (G);
    \draw [name path=C--D] (G) -- (A);
    \draw [dashed,name path=C--D] (C) -- (D); 
    \draw [dashed,name path=E--F] (E) -- (F);

    \path [name path=A--P1] (A) -- (25:10); % a bit longer, so that there is an intersection                
    \draw [name intersections={of=E--F and A--P1, by=P1}] (A) -- (P1);                          
    \node [inner sep=0pt,text width=0,anchor=east](p1) at (P1)  {};

    \path [name path=A--P2] (A) -- (37:10); % a bit longer, so that there is an intersection   
    \draw [name intersections={of=C--D and A--P2, by=P2}] (A) -- (G);  
    \draw [name path=P1--P2] (P1) -- (P2); 
    \draw [dashed,blue] (P2) -- ++(17:8);                         
    \path [name path=P2--P3] (P2) -- ++(17:10); % a bit longer, so that there is an intersection
    \path [name intersections={of=H--G and P2--P3, by=P3}];  
    \node [,text width=0,anchor=west,inner sep=0pt](p3) at (P3)  {};
    \draw (p1.east) to [out=25,in=17] (p3.west);   

\end{tikzpicture}      
\end{document}

最终图像: 在此处输入图片描述

相关内容