画出角的余角

画出角的余角

我想画一条路径或一个 n 边形的内角。我找到了帖子使用 tikz 标签角度

按照那里的代码并使用该包\usetikzlibrary{decorations.markings},我写道

\tikzset{middlearrow/.style={
        decoration={markings,
            mark= at position 0.5 with {\arrow{#1}} ,
        },
        postaction={decorate}
    }
}


\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
\def\tikz@AngleOfLine(#1)(#2)#3{%
    \pgfmathanglebetweenpoints{%
        \pgfpointanchor{#1}{center}}{%
        \pgfpointanchor{#2}{center}}
    \pgfmathsetmacro{#3}{\pgfmathresult}%
}

\begin{tikzpicture}


\coordinate (A0) at (-1,-0.3);
\coordinate (A1) at (-1.4,-1);
\coordinate (A2) at (-1,-1.8);
\coordinate (An-2) at (0.8,-1.8);
\coordinate (An-1) at (1,-1);
\coordinate (An) at (0,0);
\coordinate (An+1) at (0,-1);   

\draw[middlearrow={latex}]
(A0) -- (A1);


\draw[middlearrow={latex}]
(A1) -- (A2);

\draw[middlearrow={latex},dashed] (-1,-1.8) to [bend right] (An-2);


\draw[middlearrow={latex}]
(An-2) -- (An-1);

\draw[middlearrow={latex}]
(An-1) -- (An);


\draw[middlearrow={latex}]
(An) -- (An+1);



\node at (-1,0) {\small $A_0$};

\node at (-1.7,-1) {\small $A_1$};  

\node at (1.5,-1)  {\small $A_{n-1}$};      

\node at (0,0.2) {\small $A_{n}$};  

\node at (0,-1.25) {\small $A_{n+1}$};



\tikzAngleOfLine(A1)(A0){\AngleStart}
\tikzAngleOfLine(A1)(A2){\AngleEnd}
\draw[red,<->] (A1)+(\AngleStart:0.2cm) arc (\AngleStart:\AngleEnd:0.2 cm);

\tikzAngleOfLine(An-1)(An-2){\AngleStart}
\tikzAngleOfLine(An-1)(An){\AngleEnd}
\draw[red,<->] (An-1)+(\AngleStart:0.2cm) arc (\AngleStart:\AngleEnd:0.2 cm);

\tikzAngleOfLine(An)(An-1){\AngleStart}
\tikzAngleOfLine(An)(An+1){\AngleEnd}
\draw[red,<->] (An)+(\AngleStart:0.3cm) arc (\AngleStart:\AngleEnd:0.3 cm);


\end{tikzpicture}



\begin{tikzpicture}


\coordinate (An-1) at (0:1.2);
\coordinate (An) at (45:1.2);
\coordinate (A1) at (90:1.2);
\coordinate (A2) at (135:1.2);
\coordinate (A3) at (180:1.2);


\draw[middlearrow={latex}]
(An-1) -- (An);

\draw[middlearrow={latex}]
(An) -- (A1);

\draw[middlearrow={latex}]
(A1) -- (A2);

\draw[middlearrow={latex}]
(A2) -- (A3);

\draw[middlearrow={latex},dashed]
(180:1.2) -- (225:1.2);

\draw[middlearrow={latex},dashed]
(225:1.2) -- (270:1.2);

\draw[middlearrow={latex},dashed]
(270:1.2) -- (315:1.2);

\draw[middlearrow={latex},dashed]
(315:1.2) -- (360:1.2);


\node at (0:1.6) {\small $A_{n-1}$};
\node at (45:1.6) {\small $A_n$};
\node at (90:1.6) {\small $A_1$};
\node at (135:1.6) {\small $A_2$};
\node at (180:1.6) {\small $A_3$};



\tikzAngleOfLine(An)(An-1){\AngleStart}
\tikzAngleOfLine(An)(A1){\AngleEnd}
\draw[red,<->] (An)+(\AngleStart:0.2cm) arc (\AngleStart:\AngleEnd:0.2 cm);


\tikzAngleOfLine(A1)(An){\AngleStart}
\tikzAngleOfLine(A1)(A2){\AngleEnd}
\draw[red,<->] (A1)+(\AngleStart:0.2cm) arc (\AngleStart:\AngleEnd:0.2 cm);


\tikzAngleOfLine(A2)(A1){\AngleStart}
\tikzAngleOfLine(A2)(A3){\AngleEnd}
\draw[red,<->] (A2)+(\AngleStart:0.2cm) arc (\AngleStart:\AngleEnd:0.2 cm);
\end{tikzpicture}

我可以绘制以下内容:

在此处输入图片描述

图一中的角$\angle A_0A_1A_2$和图二中的角$\angle A_1A_2A_3$需要翻转。换句话说,我需要画一个角的补角。但是我不知道如何翻转它们。请给我一些建议。

答案1

我只会使用库中的角度angles。以下代码仍然比需要的更冗长。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{angles,decorations.markings,arrows.meta,bending}
\tikzset{middlearrow/.style={
        decoration={markings,
            mark= at position 0.5 with {\arrow{#1}} ,
        },
        postaction={decorate}
    }}
\begin{document}
\begin{tikzpicture}
 \path[node font=\small] 
  (-1,-0.3) coordinate (A0) node[above]{$A_0$}
  (-1.4,-1) coordinate (A1) node[left]{$A_1$}
  (-1,-1.8) coordinate (A2)
  (0.8,-1.8) coordinate (An-2)
  (1,-1) coordinate (An-1) node[right]{$A_{n-1}$}
  (0,0) coordinate (An) node[above]{$A_n$}
  (0,-1)  coordinate (An+1);
 \path[line cap=round,every edge/.append style={middlearrow=latex}]  
  (A0) edge (A1)
  (A1) edge (A2)
  (A2) edge[bend right,dashed] (An-2)
  (An-2) edge (An-1)
  (An-1) edge (An)
  (An) edge (An+1);
 \path[angle radius=1em,
    pic actions/.append style={draw=red,{Stealth[bend]}-{Stealth[bend]}}] 
  pic{angle=A2--A1--A0} 
  pic{angle=An--An-1--An-2} 
  pic[angle radius=1.5em]{angle=An+1--An--An-1};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容