2

This question already has an answer here:

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

marked as duplicate by CarLaTeX, Henri Menke, Zarko tikz-pgf Jul 8 '17 at 5:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You are drawing an empty node - it takes up space. Nodes has seperation space, that can be set to zero, but the node har no function, so just do not draw it. – hpekristiansen Jun 29 '17 at 20:18
  • 1
    Thanks, changing node to coordinatesolved my problem. – jagjordi Jun 29 '17 at 20:20
  • An alternative is to draw the line to the center of the node, \draw (0,0) -- (ne.center); – StefanH Jun 29 '17 at 20:28
  • It's not a duplicate @Bobyandbob, please read entirely both questions before reporting it as a duplicate. – jagjordi Jun 29 '17 at 20:44
  • @StefanPinnow That's the wrong duplicate. – Henri Menke Jul 8 '17 at 4:45
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

Not the answer you're looking for? Browse other questions tagged or ask your own question.