간단한 TikZ 다이어그램 - 여러 컨트롤이 있는 곡선

간단한 TikZ 다이어그램 - 여러 컨트롤이 있는 곡선

TikZ에서 다음 다이어그램을 그리려고 합니다.

원하는 TikZ 다이어그램

다음 코드를 작성했지만 P1과 P3에 대해 두 개의 곡선을 수행하는 방법을 잘 모르겠습니다.

\documentclass[11pt,a4paper]{report}

\usepackage[USenglish]{babel} 
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage{lmodern} 

\usepackage{tikz}
\usetikzlibrary{positioning,fit,backgrounds}

\begin{document}

\title{Test}
\author{Thomas Offer}
\date{\today}
\begin{figure}[h!]
\centering
\begin{tikzpicture}[scale=1,thick,main node/.style={rectangle,draw,minimum width=2cm,minimum height=2cm}]
    \node[main node,label=below:$M_1$] (M1) at (3,2) {};
    \node[main node,label=below:$M_2$] (M2) at (7,2) {};
    \node[main node,label=below:$M_3$] (M3) at (11,2) {};
    \draw[->] (0,2) node[left] {$P_2$} -- (14,2);
\end{tikzpicture}
\caption{Tikz test picture}
\end{figure}
\end{document}

컨트롤과 함께 그리기를 사용해 보았지만 아무 소용이 없습니다. 도움을 주시면 감사하겠습니다!

답변1

한 가지 옵션은 curve through다음 명령 일 수 있습니다.hobbytikzlibrary.

취향에 따라 곡선을 조정해야 하는 예

\documentclass[11pt,a4paper]{report}

\usepackage[USenglish]{babel} 
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage{lmodern} 


\usepackage{tikz}
\usetikzlibrary{positioning,fit,backgrounds,hobby}

\begin{document}

\title{Test}
\author{Thomas Offer}
\date{\today}
\begin{figure}[h!]
\centering
\begin{tikzpicture}[scale=1,thick,main node/.style={rectangle,draw,minimum width=2cm,minimum height=2cm}]
    \node[main node,label=below:$M_1$] (M1) at (3,2) {};
    \node[main node,label=below:$M_2$] (M2) at (7,2) {};
    \node[main node,label=below:$M_3$] (M3) at (11,2) {};
    \draw[->] (0,2) node[left] (P2) {$P_2$} -- (14,2);
    \node[below=2cm of P2] (P3){$P3$};
    \node[above=2cm of M1] (P1){$P1$};
    \path (P1-|M3.north east)--++(0:2cm) coordinate (aux);
    \draw[->] (P3.north) to[curve through={ ([xshift=-5mm]M1.210)..([xshift=5mm]M1.-20) ..([xshift=5mm]M2.200) ([xshift=5mm]M2.-30)}] (P3-|M3.south west);
    \draw[->] (P1.south) to[curve through={ ([xshift=-5mm]M2.150)..([xshift=5mm]M2.20) ..([xshift=5mm]M3.160) ([xshift=5mm]M3.30)}] (aux);
\end{tikzpicture}
\caption{Tikz test picture}
\end{figure}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보