直線和圓之間的交點並不完全一致

直線和圓之間的交點並不完全一致

我試圖獲取直線和圓之間的交點,但是當我從該點繪製到另一個點時,它並不只是從交點開始。
這是我的程式碼:

\documentclass[margin=1mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}
    \begin{tikzpicture}
        \draw [name path = circle]
        (0,0) circle (1);

        \path [name path = en1] (-3,.4)--(3,.4);
        \path [name path = en2] (-3,-.4)--(3,-.4);

        \draw [name intersections={of=en1 and circle}]
        (intersection-1) node (ne) {}
        (intersection-2) node (no) {};

        \draw [name intersections={of=en2 and circle}]
        (intersection-1) node (so) {}
        (intersection-2) node (se) {};

        \draw
        (0,0) -- (ne);
    \end{tikzpicture}
\end{document}

我的結果:
在此輸入影像描述

答案1

正如評論中所述,節點將佔用一些空間。[draw]加到節點就可以看到。若要繪製一條到交點的線,請將其指定為 acoordinate或將線繪製到節點的中心。

\documentclass[margin=1mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}
    \begin{tikzpicture}
        \draw [name path = circle]
        (0,0) circle (1);

        \path [name path = en1,draw,gray!40] (-3,.4)--(3,.4);
        \path [name path = en2,draw,gray!40] (-3,-.4)--(3,-.4);

        \draw [name intersections={of=en1 and circle}]
        (intersection-1) node[draw] (ne) {}
        (intersection-2) node (no) {};

        \draw [name intersections={of=en2 and circle}]
        (intersection-1) coordinate (so)
        (intersection-2) coordinate (se);

        \draw (0,0) -- (ne);
        \draw (0,0) -- (no.center);
        \draw (0,0) -- (se);
    \end{tikzpicture}
\end{document}

在此輸入影像描述

相關內容