绘制平分角的射线

绘制平分角的射线

通过以下代码绘制一个三角形。(在显示中,仅标记了两个顶点。在代码中,顶点标记为ABC。)我延长边ACBC。我想绘制一条射线,平分这些延长边形成的(锐角)。

我已经指定了\coordinate (A) at (0,0);\coordinate (C) at (290:3.25);;因此,我知道边的延长线AC与通过的水平线成 70 度角C。边的延长BC线与通过的水平线成70 度角C,这个角度必须用一个混乱表达式的反正切来表示!可以使用包绘制这条射线吗calc

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections}


\begin{tikzpicture}

%A is the vertex of an angle of 55 degrees; the sides of this angle are AB
%and AC. $AB = 22$ and $AC = 13$.
\coordinate (A) at (0,0);
\node (vertex_A) at ($(A) + (82.5:7.5pt)$){$A$};
\coordinate (B) at (235:5.5);
\node (vertex_B) at ($(B) + (225:7.5pt)$){$B$};
\coordinate (C) at (290:3.25);
\draw[name path=AB] (A) -- (B);
\draw[name path=AC] (A) -- (C);
\draw[name path=BC] (B) -- (C);


%These commands label the lengths of AB and of AC.
\coordinate (AB_midpoint) at ($(A)!0.5!(B)$);
\coordinate (AC_midpoint) at ($(A)!0.5!(C)$);


%These commands draw the altitude of the triangle from C. The foot of the altitude is
%labeled P.
\coordinate (P) at ($(A)!(C)!(B)$);
\draw[dashed] (C) -- (P);
\coordinate (PC_midpoint) at ($(P)!0.5!(C)$);

%The following commands make the right-angle mark.
\coordinate (U) at ($(P)!4mm!-45:(A)$);
\draw (U) -- ($(P)!(U)!(A)$);
\draw (U) -- ($(P)!(U)!(C)$);

\coordinate (S) at ($(B)!1.75!(C)$);
\coordinate (T) at ($(A)!2!(C)$);

\draw[-latex,loosely dashed,green] (C) -- (S);
\draw[-latex,loosely dashed,green] (C) -- (T);

\end{tikzpicture}


\end{document}

答案1

您可以使用calc来计算角度:

\draw let \p1=($(S)-(C)$), \p2=($(T)-(C)$), \n0={.5*atan2(\y1,\x1)+.5*atan2(\y2,\x2)} in
   (C) -- +(\n0:2);

您可以构造二分法:

\draw (C) -- ($($(C)!2cm!(S)$)!.5!($(C)!2cm!(T)$)$);

这使用分层calc计算,可能会产生问题,因此您可以事先进行计算

… let \p1=($(C)!2cm!(S)$), \p2=($(C)!2cm!(T)$) in (C) -- ($(\p1)!.5!(\p2)$) …

但是如果你定义ST与的距离相等C,例如

\path ($(C)!-2cm!(B)$) coordinate (S)
      ($(C)!-2cm!(A)$) coordinate (T);

你可以做

\draw (C) -- ($(S)!.5!(T)$);

你可以(我认为应该)把这个解决方案包装起来insert path,比如说

\tikzset{
  calc angle between/.style args={#1--#2--#3}{%
    insert path={let \p{@aux1}=($(#1)-(#2)$), \p{@aux2}=($(#3)-(#2)$),
      \n{angle}={.5*atan2(\y{@aux1},\x{@aux1})+.5*atan2(\y{@aux2},\x{@aux2})} in}}}

然后你就可以

\draw[calc angle between=S--C--T] (C) -- +(\n{angle}:2);

anglebisect(<p1>, <p2>, <p3>, <p4>)我还提供了一个由 PGFmath 提供支持的解决方案,它为您提供了一个计算线(<p1>) -- (<p2>)(<p3>) -- (<p4>)(在您的情况下<p1>等于)的方向角的函数<p3>。不幸的是,PGFmath 需要"包裹这些参数,因为它不应该对它们进行评估。

代码

\documentclass[tikz]{standalone}
\usetikzlibrary{calc,arrows.meta}
\makeatletter
\newcommand*\pgfmathanglebetweenpointsNoCorrection[2]{%
  \begingroup%
    \pgf@process{\pgfpointdiff{#1}{#2}}%
    \edef\pgf@marshall{\expandafter\noexpand\csname pgfmathatan2@\endcsname
      {\expandafter\Pgf@geT\the\pgf@y}{\expandafter\Pgf@geT\the\pgf@x}}%
    \pgf@marshall%
  \pgfmath@smuggleone\pgfmathresult\endgroup}
\pgfmathdeclarefunction{anglebisect}{4}{%
  \begingroup
    \pgfmathanglebetweenpointsNoCorrection{\pgfpointanchor{\tikz@pp@name{#1}}{center}}
                                          {\pgfpointanchor{\tikz@pp@name{#2}}{center}}%
    \let\pgfmath@temp\pgfmathresult
    \pgfmathanglebetweenpointsNoCorrection{\pgfpointanchor{\tikz@pp@name{#3}}{center}}
                                          {\pgfpointanchor{\tikz@pp@name{#4}}{center}}%
    \pgfmathadd@{\pgfmath@temp}{\pgfmathresult}%
    \pgfmathmultiply@{.5}{\pgfmathresult}%
    \pgfmath@smuggleone\pgfmathresult\endgroup}
\makeatother
\tikzset{
  calc angle between/.style args={#1--#2--#3}{%
    insert path={let \p{@aux1}=($(#1)-(#2)$), \p{@aux2}=($(#3)-(#2)$),
      \n{angle}={.5*atan2(\y{@aux1},\x{@aux1})+.5*atan2(\y{@aux2},\x{@aux2})} in}}}
\begin{document}
\begin{tikzpicture}
\path[every label/.append style={circle,inner sep=1pt}]
      (0,0)      coordinate[label=$A$] (A)
    + (235:5.5)  coordinate[label=below left:$B$] (B)
    + (290:3.25) coordinate (C)
    ($(A)!.5!(B)$)  coordinate (AB_midpoint)
    ($(A)!.5!(C)$)  coordinate (AC_midpoint)
    ($(A)!(C)!(B)$) coordinate (P)
    ($(P)!.5!(C)$)  coordinate (PC_midpoint);
\draw (A) -- (B) -- (C) -- cycle;
% or: \draw plot coordinates {(A)(B)(C)} -- cycle;

\draw[dashed] (C) -- (P);
\draw coordinate (U) at ($(P)!4mm!-45:(A)$)
  ($(P)!(U)!(A)$) -- (U) -- ($(P)!(U)!(C)$);

\draw[Latex-Latex,loosely dashed,green]
  ($(B)!1.75!(C)$) coordinate (S)
  -- (C) --
  ($(A)!2!(C)$)    coordinate (T);

\draw[line width=.2cm] let \p1=($(S)-(C)$), \p2=($(T)-(C)$),
                 \n0={.5*atan2(\y1,\x1)+.5*atan2(\y2,\x2)} in
  (C) -- +(\n0:2);

\draw[line width=.15cm,red]    (C) -- ($($(C)!2cm!(S)$)!.5!($(C)!2cm!(T)$)$);
\draw[line width=.1cm,white] (C) -- +({anglebisect("C","S","C","T")}:1);

\draw[dashed,thick, calc angle between=S--C--T] (C) -- +(\n{angle}:2);

\path ($(C)!-2cm!(B)$) coordinate (S)
      ($(C)!-2cm!(A)$) coordinate (T);
\draw[thick,dashed,blue!50,dash phase=3pt] (C) -- ($(S)!.5!(T)$);
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

答案2

水平线与 之间的角度BC可以通过以下方式计算\pgfmathanglebetweenpoints

\pgfmathanglebetweenpoints{\pgfpointanchor{B}{center}}{\pgfpointanchor{C}{center
\let\AngleTmp\pgfmathresult
\pgfmathsetmacro\RayAngle{(-70 + \AngleTmp)/2}

结果

答案3

如果你愿意接受一个新的软件包,那么你可以使用tkz-euclide它并将其添加到你的序言中:

\usepackage{tkz-euclide}
\usetkzobj{all}

然后使用以下命令:

\tkzDefLine[bisector](T,C,S)\tkzGetPoint{a}
\tkzDrawSegment[red, dotted](C,a)

输出如下:

图1

答案4

这是代码的简化版本。使用两个点绘制角平分线(S),并将(T)其定位在与 的距离相同的位置(C)。仅calc使用库。

\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{calc}

\begin{document}
  \begin{tikzpicture}
    % draw the triangle
    \path (0,0) coordinate (A) node[above] {$A$}
        (235:5.5) coordinate (B) node[below left]{$B$}
        (290:3.25) coordinate (C);
    \draw (A) -- (B) -- (C) -- cycle;

    % draw dashed height
    \draw[dashed] (C) -- ($(A)!(C)!(B)$) coordinate (P);

    %The following commands make the right-angle mark.
    \draw ($(P)!4mm!(A)$) -- ([turn]90:4mm) -- ([turn]-90:4mm);

    % draw the opposit angle and the bisector in red
    \draw[-latex,loosely dashed,green] (C) -- ($(C)!-2cm!(B)$) coordinate (S) -- ([turn]0:15mm);
    \draw[-latex,loosely dashed,green] (C) -- ($(C)!-2cm!(A)$) coordinate (T) -- ([turn]0:5mm);
    \draw[thick, red] (C) -- ($(S)!.5!(T)$) -- ([turn]0:15mm);
  \end{tikzpicture}
\end{document}

在此处输入图片描述

笔记:[turn]直角标记中的第一个对我来说是一个谜,但它有效。

相关内容