TikZ:为什么找不到第二个路口?

TikZ:为什么找不到第二个路口?

我正在尝试构造虚线曲线的切线,但 TeX 告诉我没有已知的名为 Intersection-2 的形状。

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, intersections, arrows}
\begin{document}
\begin{tikzpicture}[line cap = round, line join = round, >=triangle 45]
  \coordinate (P1) at (2, -1);
  \coordinate (P2) at (6, -1);
  \coordinate (E) at (4, -1);
  \draw (E) -- ++(150:6cm) node[pos =.5, scale = .7,
    fill = white, inner sep = 0cm] {402,000 km} coordinate (M);
  \draw[name path = line1, dashed] (3, -2) .. controls (5.8, -1.25) and
  (5, 0) .. (M);
  \draw (P1) -- (P2);
  \draw[-latex] (5, -1) arc (0:150:1cm) node[above = 1pt, scale = .75]
  at (4.25, 0) {\(150^{\circ}\)};
  \path[name path = aux] (M) circle [radius = 1bp];
  \draw[name intersections = {of = line1 and aux}, -latex, red, thick] (M) 
  -- ($(intersection-1)!.75cm!(intersection-2)$);
\end{tikzpicture}
\end{document}

这条线line1应该与圆相交,aux但显然它只相交一次。我该怎么做才能解决这个问题?

答案1

您可以aux通过添加draw选项使圆可见。然后您会看到确实没有第二个交点,因为该点就在曲线的末端。

intersection-2在这种情况下,您可以通过替换切点本身来绘制切线M

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, intersections, arrows}
\begin{document}
\begin{tikzpicture}[line cap = round, line join = round, >=triangle 45]
  \coordinate (P1) at (2, -1);
  \coordinate (P2) at (6, -1);
  \coordinate (E) at (4, -1);
  \draw (E) -- ++(150:6cm) node[pos =.5, scale = .7,
    fill = white, inner sep = 0cm] {402,000 km} coordinate (M);
  \draw[name path = line1, dashed] (3, -2) .. controls (5.8, -1.25) and
  (5, 0) .. (M);
  \draw (P1) -- (P2);
  \draw[-latex] (5, -1) arc (0:150:1cm) node[above = 1pt, scale = .75]
  at (4.25, 0) {\(150^{\circ}\)};
  \path[draw, name path = aux] (M) circle [radius = 1bp];
  \draw[name intersections = {of = line1 and aux}, -latex, red, thick] (M) 
  -- ($(intersection-1)!.75cm!(M)$);
\end{tikzpicture}
\end{document}

相关内容