
線と円の交点を取得しようとしていますが、その点から別の点に描画すると、交点から開始されません。
これが私のコードです:
\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}