在 Tikz 中沿貝塞爾曲線找出座標

在 Tikz 中沿貝塞爾曲線找出座標

假設我在 Tikz 中定義了一條貝塞爾曲線:

\documentclass{article}
\usepackage{tikz}

\begin{document} 
\begin{tikzpicture}
 \draw (0,0) .. controls (1,2) and  (2,-1) .. (4,0);
\end{tikzpicture}
\end{document} 

我想找到沿著曲線的座標,例如沿著曲線的 30% 和 60% 處的座標。我想用紅點指示它們的位置,並從座標開始繪製箭頭到不同的方向。

它們是沿著貝塞爾曲線返迴座標的簡單命令嗎?謝謝。

答案1

您可以markings在包括貝塞爾曲線在內的任何路徑上使用。mark=at position 0.30表示沿路徑 30% 的標記。

\documentclass[border=0.2 cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,arrows}
\begin{document}
\begin{tikzpicture}[%
  decoration={markings,
    mark=at position 0.30 with {\coordinate (A); \fill[red] circle [radius=2pt];},
    mark=at position 0.60 with {\coordinate (B); \fill[red] circle [radius=2pt];}
  }]

\draw[postaction={decorate}] (0,0) .. controls (1,2) and  (2,-1) .. (4,0);
\draw[->] (A) -- (1,1);
\draw[->] (B) -- (2,2);
\end{tikzpicture}
\end{document}

標記的貝塞爾曲線

相關內容