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}
name path global=
instead ofname path
.