TikZ:如何延长一行以匹配另一行(糟糕的标题,我能做的最好的事情)

TikZ:如何延长一行以匹配另一行(糟糕的标题,我能做的最好的事情)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc, arrows, intersections}
\begin{document}
\begin{tikzpicture}[line cap = round, line join = round, >=triangle 45,
    fixed point arithmetic]
    \coordinate (P1) at (-2, 0);
    \coordinate (P2) at (2.5, 0);
    \coordinate (P3) at (2, 0);

    \draw (P1) -- (P2);
    \draw[red] (P3) circle (.1cm);
    \path[name path = line] (P1) -- (70: 4.5cm and 2.5cm);
    \path[name path = arc] (P3) arc (0:70: 4cm and 2cm) coordinate (P4);
    \path[name intersections = {of = line and arc, by = P4}];

    \begin{scope}
      \clip (P4) rectangle (P3);
      \draw (P3) arc (0:70: 4cm and 2cm);
    \end{scope}

    \draw[-latex] (P1) -- (P4) node[above, scale = .75, pos = .5, fill = white,
    inner sep = 0cm] {\(\mathbf{r}\)};

    \draw[orange] let
      \p1 = (P1),
      \p3 = (P3),
      \p4 = (P4),
      \n1 = {atan2(\x3 - \x1, \y3 - \y1)},
      \n2 = {atan2(\x4 - \x1, \y4 - \y1)},
      \n3 = {.75cm}
    in (P1) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
    node [scale = .75, shift = {(.5cm, -.25cm)}] {\(\nu\)};

    \path[name path = aux] (P4) circle [radius = 1bp];

    \draw[name intersections = {of = arc and aux}, -latex] (P4) --
    ($(intersection-2)!1cm!(intersection-1)$);
    \draw[-latex] (P4) -- ($(P4)!1cm!-90:(P1)$);
\end{tikzpicture}
\end{document}

在此处输入图片描述

我怎样才能将与圆弧末端相切的线延长到垂直线的长度?我知道我可以\path在第一条垂直线的末端再画一条垂直线,然后画一条更长的切线\path,标记交点,然后将切线改​​为新标记的交点。但是,一定有更好的方法。

答案1

如果在切向箭头的末尾命名坐标(P5),则可以使用calc库的投影语法将垂直箭头绘制到正确的长度。

使用投影语法,表达式

($(A)!(C)!(B)$)

描述在从到 的C线上的投影。这可以与旋转语法结合使用:AB

($(A)!(C)!90:(B)$)

描述在从到 的C线上的投影,该线旋转90 度之后。ABA

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, arrows, intersections}
\begin{document}
\begin{tikzpicture}[line cap = round, line join = round, >=triangle 45]
    \coordinate (P1) at (-2, 0);
    \coordinate (P2) at (2.5, 0);
    \coordinate (P3) at (2, 0);

    \path[name path = line] (P1) -- (70: 4.5cm and 2.5cm);
    \path[name path = arc] (P3) arc (0:70: 4cm and 2cm) coordinate (P4);
    \path[name intersections = {of = line and arc, by = P4}];

    \begin{scope}
      \clip (P4) rectangle (P3);
      \draw (P3) arc (0:70: 4cm and 2cm);
    \end{scope}

    \draw[-latex] (P1) -- (P4);
    \path[name path = aux] (P4) circle [radius = 1bp];

    \draw[name intersections = {of = arc and aux}, -latex] (P4) --
    ($(intersection-2)!1.2cm!(intersection-1)$) coordinate (P5);
    \draw[-latex] (P4) -- ($(P4)!(P5)!-90:(P1)$);

\end{tikzpicture}
\end{document}

相关内容