考虑
\documentclass[margin = 12mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{bending}
\begin{document}
\begin{tikzpicture}
\draw[bend right = 40, name path = a] (0, 0) edge (2, 0);
\draw[bend left = 40, name path = b] (0, -.5) edge (2, -.5);
\path[name intersections = {of = a and b}];
\draw[name path = c] (3.5, 0) -- (3, -.5);
\draw[name path = d] (3.5, -.5) -- (3, 0);
\path[name intersections = {of = c and d}];
\fill (intersection-1) circle (1pt);
\end{tikzpicture}
\end{document}
我期望实心圆会出现在两条曲线首次相交的位置。但实际上两条曲线的交点并未标记。
我也尝试用床身 ( ) 来命名弯曲路径postaction = {name path = a}
,但交叉点仍然没有出现。
我怎样才能解决这个问题没有使用实际的贝塞尔曲线(.. controls ..
)?
答案1
你可以:
- 命名您的
edge
s:
\documentclass[tikz, margin = 1mm]{standalone}
\usetikzlibrary{bending, intersections}
\begin{document}
\begin{tikzpicture}
\draw[bend right = 40] (0, 0) edge[name path=a] (2, 0);
\draw[bend left = 40] (0, -.5) edge[name path=b] (2, -.5);
\path[name intersections={of=a and b}];
\fill (intersection-1) circle[radius=1pt];
\draw[name path = c] (3.5, 0) -- (3, -.5);
\draw[name path = d] (3.5, -.5) -- (3, 0);
\end{tikzpicture}
\end{document}
或者
- 使用
to
操作:
\documentclass[tikz, margin = 1mm]{standalone}
\usetikzlibrary{bending, intersections}
\begin{document}
\begin{tikzpicture}
\draw[bend right = 40, name path=a] (0, 0) to (2, 0);
\draw[bend left = 40, name path=b] (0, -.5) to (2, -.5);
\path[name intersections={of=a and b}];
\fill (intersection-1) circle[radius=1pt];
\draw[name path = c] (3.5, 0) -- (3, -.5);
\draw[name path = d] (3.5, -.5) -- (3, 0);
\end{tikzpicture}
\end{document}
也可能(更好?):
\draw[name path=a] (0, 0) to[bend right = 40] (2, 0);
\draw[name path=b] (0, -.5) to[bend left = 40] (2, -.5);
两个代码都产生相同的输出:
请注意,这circle (1pt)
是一个过时的语法,可以导致问题(也可以看看这里, 和pgfplots
期号 232)。最好circle[radius=1pt]
按照我上面的做法来使用。