5

I have constructed a circle using the through package. I would like to create a coordinate at the intersection of this circle and another line. Is there a way to do this? I tried to name the path created with circle through, but could not get that to work.

Here is the code. I would like to calculate the intersection of the red circle and the dashed line or path named "p0." The red circle is constructed to pass through the point "x1." I believe the problem has something to do with the `scope' command.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,through}
\begin{document}
\begin{tikzpicture}
\coordinate (x1) at (.4,1.2);
\draw[name path=p0,dashed] (0,.8) node[left] {$p_{0}$} -- ++(2.7,0);

\begin{scope}
\node [draw,red] at (2.4,1.9) [circle through=(x1)] {};
\end{scope}

\end{tikzpicture}
\end{document}

Interestingly, the following code, does not compile, where I try to name the path as advised by @Qrrbrbirlbel:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,through}
\begin{document}
\begin{tikzpicture}
\coordinate (x1) at (.4,1.2);
\draw[name path=p0,dashed] (0,.8) node[left] {$p_{0}$} -- ++(2.7,0);

\begin{scope}
\node [draw,red, name path=p1] at (2.4,1.9) [circle through=(x1)] {};
\end{scope}

\fill[name intersections={of=p0 and p1}] (intersection-1) circle (2pt) node[below left] {$x$};
\end{tikzpicture}
\end{document}

However, the code does work if there is another item drawn in between the end of the scope command and the attempt to calculate an intersection. The following code is essentially the one posted by @Qrrbrbirlbel, which works even with the scope command. The only difference is that we draw the "x1" node before trying to create an intersection.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,through}
\begin{document}
\begin{tikzpicture}
\coordinate (x1) at (.4,1.2);
\draw[name path=p0,dashed] (0,.8) node[left] {$p_{0}$} -- ++(2.7,0);

\begin{scope}
\node [draw,red, name path=p1] at (2.4,1.9) [circle through=(x1)] {};
\end{scope}

\fill[black] (x1) circle (2pt) node[left] {$x_{1}$};

\fill[name intersections={of=p0 and p1}] (intersection-1) circle (2pt) node[below left] {$x$};
\end{tikzpicture}
\end{document}
1
  • The comments below @Qrrbrbirlbel's answer explain that one must use name path global= instead of name path.
    – profj
    Aug 8, 2013 at 3:11

1 Answer 1

5

Naming the path of the node works for me:

Code

\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{intersections,through}
\begin{document}
\begin{tikzpicture}
\coordinate (x1) at (.4,1.2);
\draw[name path=p0,dashed] (0,.8) node[left] {$p_{0}$} -- ++(2.7,0);

\node [draw,red, name path=p1] at (2.4,1.9) [circle through=(x1)] {};
\fill[black] (x1) circle (2pt) node[left] {$x_{1}$};

\fill[name intersections={of=p0 and p1}] (intersection-1) circle (2pt) node[below left] {$x$};
\end{tikzpicture}
\end{document}

Output

enter image description here

2
  • Sorry, in an attempt to strip down my code, I eliminated the source of the problem. I have now edited my original question to include a scope command, which creates the issue. I have also explained how placing a command in between the scope and the intersection command solve the problem. But, I do not understand why.
    – profj
    Aug 8, 2013 at 0:46
  • 2
    @stanford202 You need name path global=p1 then. Though, it is interesting that it works without global if there is another path between the end of the scope and the name intersections path. Aug 8, 2013 at 0:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .