计算“范围”所包围的路径与另一条路径之间的交集

计算“范围”所包围的路径与另一条路径之间的交集

我使用包构造了一个圆through。我想在这个圆和另一条线的交点处创建一个坐标。有办法吗?我尝试使用命名创建的路径circle through,但无法使其工作。

这是代码。我想计算红色圆圈与名为“p0”的虚线或路径的交点。红色圆圈的构造经过点“x1”。我相信问题与“scope”命令有关。

\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}

有趣的是,当我尝试按照@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}

但是,如果在命令结束scope和尝试计算交点之间绘制了另一个项目,则代码确实有效。以下代码本质上是 @Qrrbrbirlbel 发布的代码,即使使用该scope命令也可以工作。唯一的区别是我们在尝试创建交点之前绘制了“x1”节点。

\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

命名节点的路径对我来说是有用的:

代码

\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}

输出

在此处输入图片描述

相关内容