TikZ 交叉指令具有奇怪的行為

TikZ 交叉指令具有奇怪的行為

我試著將一些節點放在圓與一些平分線的交點。然而,交叉路口的行為並不像我想像的那樣。

文字錯誤的應該放置在圓圈和灰線的交點處,但它不知何故位於一個明顯隨機的位置:

現在的情況

此外,如果註解行未註釋,則兩個交點將放置在完全相同的位置:

仍然是錯誤和奇怪的

(不過,藍色文字正是它應該在的位置。)

有人可以解釋我做錯了什麼嗎?我不明白為什麼在這兩種情況下節點都被放置在錯誤的位置。

先致謝!

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\begin{figure}
    \centering
        \begin{tikzpicture}
            \draw[thick,dashed, name path=circ] (2,2) circle (2cm);
            
            \begin{scope}[shift={(2,2)}]
                \filldraw (165:2) node[left=3.5pt] (c) {\large $c$} circle (3pt);
                \filldraw (225:2) node[below=3.5pt] (b) {\large $b$} circle (3pt);
                %\filldraw (135:2) node[above=3.5pt] (a) {\large $a$} circle (3pt);
            \end{scope}  
            
            %\path[shorten >=-0.5cm,-, name path= path1] let \p1=($ (a) !.5! (b) $) in (2,2) -- ($(\p1)+(5,0)$);
            %\draw[name intersections = {of =circ and path1}] (intersection-1) node[blue] (ab) {\Large right};
            \path[shorten <= -0.5cm,-, name path=path3] let \p1=($ (b) !.5! (c) $) in (\p1) edge[gray] (2,2);
            \draw[name intersections={of=circ and path3}] (intersection-1) node (bc) {wrong};
        \end{tikzpicture}
\end{figure}
\end{document}

答案1

首先確保你的 MWE 確實可以編譯,這裡\begin{document}和 tikz 函式庫calc遺失了。

其次,這裡的問題是,在\path[shorten <= -0.5cm,-, name path=path3]shorten部分中不會添加到路徑的長度(可用於計算的部分),它僅添加到顯示的版本中。因此,用於計算交點的線段完全在圓內,並且您會收到有關未找到它的錯誤。

這似乎有效

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections,calc}
\begin{document}
\begin{tikzpicture}
  \draw[thick,dashed, name path=circ] (2,2) circle (2cm);
  
  \begin{scope}[shift={(2,2)}]
    \filldraw (165:2) node[left=3.5pt] (c) {\large $c$} circle (3pt);
    \filldraw (225:2) node[below=3.5pt] (b) {\large $b$} circle (3pt);
    % \filldraw (135:2) node[above=3.5pt] (a) {\large $a$} circle (3pt);
  \end{scope}  
  
  % \path[shorten >=-0.5cm,-, name path= path1] let \p1=($ (a) !.5! (b) $) in (2,2) -- ($(\p1)+(5,0)$);
  % \draw[name intersections = {of =circ and path1}] (intersection-1) node[blue] (ab) {\Large right};
  % \path[shorten <= -0.5cm,-, name path=path3] let \p1=($
  % (b) !.5! (c) $) in (\p1) edge[gray] (2,2);
  
  \coordinate (d) at ($(b) !.5! (c) $);
  \coordinate (o) at (2,2);
  \draw[name path=path3] (o) -- ($(o)!1.5!(d)$);
  \draw[name intersections={of=circ and path3,by=e}] (e) node (bc) {wrong};
\end{tikzpicture}
\end{document}

我切換到獨立課程,因為它更適合此類問題。也刪除了figureenv,因為它與這個問題無關。

相關內容