
Я пытаюсь получить точку пересечения между линией и окружностью, но когда я рисую от этой точки до другой, она не начинается прямо на пересечении.
Вот мой код:
\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]
к узлу. Чтобы нарисовать линию до пересечения, либо укажите его как a 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}