线与圆的交点没有完全连通

线与圆的交点没有完全连通

我试图获取一条线和一个圆之间的交点,但是当我从该点绘制到另一个点时,它并不只是从交点开始。
这是我的代码:

\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]到节点来查看它。要绘制一条到交叉点的线,请将其指定为coordinate或绘制到节点中心的线。

\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}

在此处输入图片描述

相关内容