使用“angles”库中的“pic”构建文本路径

使用“angles”库中的“pic”构建文本路径

我正在尝试制作如下所示的多边形。但我手动输入了角度标题,如您在代码中看到的。您有什么想法可以以更智能的方式做到这一点吗?

输出

这是我的代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{quotes,angles,calc,plotmarks}
\usetikzlibrary{decorations.text}

\newcommand{\escala}{.02} % escala
\tikzset{MeuAngulo/.style={draw=blue,<-,angle eccentricity=1.2,angle radius=25pt,semithick}}

\begin{document}
\begin{tikzpicture}[xscale=\escala,yscale=\escala]
%The points
\coordinate (A) at (294,254);
\coordinate (B) at (120,351);
\coordinate (C) at (0,180);
\coordinate (D) at (89,0);
\coordinate (E) at (240,100);

%The polygon
\draw[thick] (A) node[above] {A} -- 
             (B) node[above] {B} -- 
             (C) node[left] {C} -- 
             (D) node[below] {D} -- 
             (E) node[right] {E} --
             (A) 
pic["",MeuAngulo,angle eccentricity=1.8] {angle=B--A--E}    
pic["",MeuAngulo,angle eccentricity=1.4] {angle=C--B--A}
pic["",MeuAngulo,angle eccentricity=1.9] {angle=D--C--B}
pic["",MeuAngulo,angle eccentricity=1.3] {angle=E--D--C} 
pic["",MeuAngulo,angle eccentricity=1.8] {angle=A--E--D}
;    

% The problem is here. I appreciate if you do this easily, some think like:
% pic["",MeuAngulo,angle eccentricity=1.8] {angle=A--E--D} \path [postaction={decorate,decoration={text along path,text= $99{^\circ}48'54''$~}}]

\path [postaction={decorate,decoration={text along path, 
text= $99{^\circ}48'54''$~}}] (275,210) arc [start angle=250.68, end angle=150.86, radius=48];

\path [postaction={decorate,decoration={text along path, 
text= $95{^\circ}55'15''$~}}] (160,325) arc [start angle=330.86, end angle=234.94, radius=48];

\path [postaction={decorate,decoration={text along path, 
text= $118{^\circ}37'50''$~}}] (43,140) arc [start angle=-60, end angle=100, radius=48];

\path [postaction={decorate,decoration={text along path, 
text= $82{^\circ}47'42''$~}}] (70,50) arc [start angle=150, end angle=40, radius=48];

\end{tikzpicture}
\end{document}

答案1

这是简化事情的一种方法。deco angle是一个pic基于的angle,它接受两个参数。第二个是要指定的角度,作为路径的装饰。如下所示,您可以继续angle以正常方式使用。

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{quotes,angles,calc,plotmarks,decorations.text}

\newcommand{\escala}{.02} % escala
\tikzset{MeuAngulo/.style={draw=blue,<-,angle eccentricity=1.2,angle radius=25pt,semithick}}

\makeatletter
\tikzset{
  pics/deco angle/.style n args = 2{
    setup code  = \tikz@lib@angle@parse#1\pgf@stop,
    background code = \tikz@lib@angle@background#1\pgf@stop,
    foreground code = \tikz@lib@decoangle@foreground#1{#2}\pgf@stop,
  },
  pics/angle/.default=A--B--C,
  angle eccentricity/.initial=.6,
  angle radius/.initial=5mm
}

\def\tikz@lib@decoangle@foreground#1--#2--#3#4\pgf@stop{%
  \path [name prefix ..] [pic actions, fill=none, shade=none]
  ([shift={(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)}]#2.center)
    arc [start angle=\tikz@start@angle@temp, end
    angle=\tikz@end@angle@temp, radius=\tikz@lib@angle@rad pt];
  \path [name prefix ..] [fill=none, shade=none, decorate, decoration={text along path, text={$|\scriptstyle|~#4~||$}}]
  ([shift={(\tikz@end@angle@temp:\tikz@lib@angle@rad+2 pt)}]#2.center)
    arc [start angle=\tikz@end@angle@temp, end angle=\tikz@start@angle@temp, radius=\tikz@lib@angle@rad+2 pt];
}
\makeatother

\begin{document}
  \begin{tikzpicture}[xscale=\escala,yscale=\escala]
    %The points
    \coordinate (A) at (294,254);
    \coordinate (B) at (120,351);
    \coordinate (C) at (0,180);
    \coordinate (D) at (89,0);
    \coordinate (E) at (240,100);

    %The polygon
    \draw[thick] (A) node[above] {A} --
      (B) node[above] {B} --
      (C) node[left] {C} --
      (D) node[below] {D} --
      (E) node[right] {E} --
      (A)
      pic["", MeuAngulo, angle eccentricity=1.8] {deco angle={B--A--E}{99{^\circ}48'54''}}
      pic["", MeuAngulo, angle eccentricity=1.4] {deco angle={C--B--A}{95{^\circ}55'15''}}
      pic["", MeuAngulo, angle eccentricity=1.9] {deco angle={D--C--B}{118{^\circ}37'50''}}
      pic["", MeuAngulo, angle eccentricity=1.3] {deco angle={E--D--C}{82{^\circ}47'42''}}
      pic["", MeuAngulo, angle eccentricity=1.8] {angle=A--E--D}
      ;

  \end{tikzpicture}
\end{document}

装饰角

答案2

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{quotes,angles}

\begin{document}
    \begin{tikzpicture}
        \path[draw ] (0,0) node[left] (6) {6}
        -- (1.5,-1) node[below] (5) {5}
        -- (3.5, -0.8) node[below] (4) {4}
        -- (6,0.75) node[right] (3) {3}
        -- (3.5, 2) node[above] (2) {2}
        -- (1,2) node[above] (1) {1}
        -- cycle;
\coordinate (a) at (0,0);   % 6
\coordinate (b) at (1.5,-1);  % 5
\coordinate (c) at (3.5,-0.8); % 4      
\coordinate (d) at (6,0.75);    %3
\coordinate (e) at (3.5, 2);  %2
\coordinate (f) at (1,2);   % 1


%1
\draw pic[draw,fill=green!30,angle radius=0.4cm,"$  30 ^ \circ
$" shift={(2mm,-5mm)}] {angle= a--f--e};

%6      
\draw pic[draw,fill=green!30,angle radius=0.4cm,"$ 60 ^ \circ$" shift={(4mm,2mm)}] {angle= b--a--f};


%5
\draw pic[draw,fill=green!30,angle radius=0.4cm,"$\beta$" shift={(0mm,4mm)}] {angle= c--b--a};

%4      
\draw pic[draw,fill=green!30,angle radius=0.4cm,"$\alpha$" shift={(0mm,4mm)}] {angle= d--c--b};

%3
\draw pic[draw,fill=green!30,angle radius=0.4cm,"$\gamma$" shift={(-5mm,0mm)}] {angle= e--d--c};

%2
\draw pic[draw,fill=green!30,angle radius=0.4cm,"$\gamma$" shift={(0mm,-5mm)}] {angle= f--e--d};
        
        
\end{tikzpicture}

相关内容