2

I'm trying to get the intersection point between a line and a circle but then when I draw from that point to another it does not start just at the intersection.
Here is my code:

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

And my result:
enter image description here

Bernard
  • 271,350
jagjordi
  • 794

1 Answers1

5

As stated in the comments a node will occupy some space. You can see it by adding [draw] to the node. To draw a line to the intersection either specify it as a coordinate or draw the line to the center of the node.

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

enter image description here

StefanH
  • 13,823