TikZ 在图片中使用 \tkzMarkAngle

TikZ 在图片中使用 \tkzMarkAngle

我正在尝试绘制一些彭罗斯拼贴画以便了解有关 tikz 的更多信息,现在我可以制作图片并放置它们。

但我不能标记角度:如果我\tkzMarkAngle在图片中使用(这是理想的),我会得到一个错误(或者pic如果我添加则失败\usepackage{tkz-euclide}

我的解决方法也不起作用:圆弧没有位于我预期的中心(见图)

梅威瑟:

\documentclass[tikz,border=4]{standalone}
\tikzset{
pics/dart/.style = {
    code ={ %
    \draw (0,0)                node(O1){}
       -- (0:\PhiLen)          node(O2){}
       -- ([turn]+144:\Len)    node(O3){} 
       -- ([turn]-36:\Len)     node(O4){}
       -- cycle;          
    \draw[dashed] (O1) -- (O3); 
%  \tkzMarkAngle[color=green,size=\BigAngLen](O3,O2,O4)  %ERROR
%  \tkzMarkAngle[color=red,size=\SmallAngLen](O4,O1,O3)  $ERROR
  \draw[green] (O1) arc (0:72:\OverPhiLen);              %Strange
  \draw[red] (O3)  arc (144:288:\OverPhiLen);            %Strange
           } } }

\begin{document}
\begin{tikzpicture}
\pgfmathsetlengthmacro{\Len}{5cm};
\pgfmathsetlengthmacro{\Phi}{1.6180339};
\pgfmathsetlengthmacro{\PhiLen}{\Len * \Phi }; 
\pgfmathsetlengthmacro{\OverPhiLen}{\Len / \Phi };
\pgfmathsetlengthmacro{\BigAngLen}{ \Len / \Phi}; 
\pgfmathsetlengthmacro{\SmallAngLen}{ \BigAngLen / \Phi};
\foreach \s in {0,72,144,216,288}
\draw (1,0) pic [rotate=\s] {dart};
\end{tikzpicture}
\end{document}

在此处输入图片描述

当我真正想要这样的东西时: 在此处输入图片描述 (重复几次)
我错过了什么?

附言:我正在做这件事:我该如何给角度添加标签?(是的,我很快也会开始研究彭罗斯风筝)。

我已经看过了非常好的入门书

提前致谢,卡尔

答案1

你想要这样的东西吗?

可能拟合弧

\documentclass[border=10pt,tikz,multi]{standalone}
\tikzset{%
  pics/dart/.style = {%
    code = {%
      \draw [pic actions] (0,0) coordinate(o1)
      -- (0:\PhiLen) coordinate (o2)
      -- ([turn]144:\Len) coordinate (o3)
      -- ([turn]-36:\Len) coordinate (o4)
      -- cycle;
      \draw[dashed, pic actions] (o1) -- (o3);
      \draw[green, pic actions] (o1) +(\OverPhiLen,0) arc (0:72:\OverPhiLen);
      \draw[red, pic actions] (o3) ++(-36:\OverPhiLen)  arc (288:144:\OverPhiLen);
    }
  }
}
\begin{document}
\begin{tikzpicture}
  \pgfmathsetlengthmacro{\Len}{5cm};
  \pgfmathsetlengthmacro{\Phi}{1.6180339};
  \pgfmathsetlengthmacro{\PhiLen}{\Len * \Phi };
  \pgfmathsetlengthmacro{\OverPhiLen}{\Len / \Phi };
  \pgfmathsetlengthmacro{\BigAngLen}{ \Len / \Phi};
  \pgfmathsetlengthmacro{\SmallAngLen}{ \BigAngLen / \Phi};
  \foreach \s in {0,72,144,216,288}
  \draw (1,0) pic [rotate=\s] {dart};
\end{tikzpicture}
\end{document}

这是通过添加箭头和数字来标记角度的版本。我不确定这些是否是您想要标记的角度,但大概可以根据需要修改这个想法。以下是想法:

\documentclass[border=10pt,tikz,multi]{standalone}
\usetikzlibrary{arrows.meta,bending}
\begin{document}
\tikzset{%
  dart label/.style={%
    midway, fill=white
  },
  pics/dart/.style = {%
    code = {%
      \draw [pic actions] (0,0) coordinate(o1)
      -- (0:\PhiLen) coordinate (o2)
      -- ([turn]144:\Len) coordinate (o3)
      -- ([turn]-36:\Len) coordinate (o4)
      -- cycle;
      \draw [dashed, pic actions] (o1) -- (o3);
      \draw [green!75!black,  -{Stealth[bend]}, pic actions] (o1) +(\OverPhiLen,0) arc (0:72:\OverPhiLen);
      \path [green!75!black, pic actions] (o1) +(.75*\OverPhiLen,0) arc (0:72:.75*\OverPhiLen) node [dart label] {72};
      \draw [red,  -{Stealth[bend]}, pic actions] (o3) ++(-36:\SmallAngLen)  arc (-36:-252:\SmallAngLen);
      \path [red, pic actions] (o3) ++(-36:.5*\SmallAngLen)  arc (-36:-252:.5*\SmallAngLen) node [dart label] {216};
      \draw [blue,  -{Stealth[bend]}, pic actions] (o3) ++(-36:.75*\SmallAngLen)  arc (-36:108:.75*\SmallAngLen);
      \path [blue, pic actions] (o3) ++(-36:.5*\SmallAngLen)  arc (-36:108:.5*\SmallAngLen) node [dart label] {144};
    }
  }
}
\begin{tikzpicture}
  \pgfmathsetlengthmacro{\Len}{5cm};
  \pgfmathsetlengthmacro{\Phi}{1.6180339};
  \pgfmathsetlengthmacro{\PhiLen}{\Len * \Phi };
  \pgfmathsetlengthmacro{\OverPhiLen}{\Len / \Phi };
  \pgfmathsetlengthmacro{\BigAngLen}{ \Len / \Phi};
  \pgfmathsetlengthmacro{\SmallAngLen}{ \BigAngLen / \Phi};
  \foreach \s in {0,72,144,216,288}
  \draw (1,0) pic [rotate=\s] {dart};
\end{tikzpicture}
\end{document}

标记角度

答案2

在此处输入图片描述

可以在和sqrt(2)-1之间任意改变。01

\documentclass[tikz,border=4]{standalone}
\usetikzlibrary{through,calc,angles}
\usepackage{siunitx}

\tikzset{
pics/dart/.style = {
    code ={ %
    \begin{scope}
    \clip[draw] (0,0)       coordinate (O1)
       -- (0:\PhiLen)       coordinate (O2)
       -- ([turn]+144:\Len) coordinate (O3)
       -- ([turn]-36:\Len)  coordinate (O4)
       -- cycle;          
    \draw[dashed] (O1) -- (O3);
    \coordinate (O5) at ($(O1)!sqrt(2)-1!(O3)$) ;
    \coordinate (O6) at ($(O1)!2/3!(O3)$) ;
    \node [draw,green] at (O1) [circle through=(O5)] {} ;
    \node [draw,red] at (O3) [circle through=(O5)] {} ;
    \node[green,fill=white] at ($(O1)!.15!(O3)$) {\ang{72}} ;
    \node[red,fill=white] at ($(O1)!.85!(O3)$) {\ang{216}} ;
    \node at ($(O2)!.2!(O6)$) {\ang{36}} ;
    \node at ($(O4)!.2!(O6)$) {\ang{36}} ;
    \end{scope}
}}}
\begin{document}
\begin{tikzpicture}
\pgfmathsetlengthmacro{\Len}{5cm};
\pgfmathsetlengthmacro{\Phi}{1.6180339};
\pgfmathsetlengthmacro{\PhiLen}{\Len * \Phi }; 
\pgfmathsetlengthmacro{\OverPhiLen}{\Len / \Phi };
\pgfmathsetlengthmacro{\BigAngLen}{ \Len / \Phi}; 
\pgfmathsetlengthmacro{\SmallAngLen}{ \BigAngLen / \Phi};
\foreach \s in {0,72,144,216,288} {%
\draw (1,0) pic [rotate=\s] {dart};
}

\end{tikzpicture}
\end{document}

答案3

我不知道你尝试过什么tkz-euclide,但在添加之后

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

\tkzMarkAngle运行正常。但是你使用了错误的坐标,所以它们被修改了。我还将node改为coordinateO1

在此处输入图片描述

\documentclass[tikz,border=4mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\tikzset{
pics/dart/.style = {
    code ={ %
    \draw (0,0)                coordinate(O1)
       -- (0:\PhiLen)          coordinate(O2)
       -- ([turn]+144:\Len)    coordinate(O3) 
       -- ([turn]-36:\Len)     coordinate(O4)
       -- cycle;          
    \draw[dashed] (O1) -- (O3); 
  \tkzMarkAngle[color=green,size=\BigAngLen](O4,O3,O2)
  \tkzLabelAngle[color=green,fill=white,size=\BigAngLen,pos=-0.5](O4,O3,O2){$216$}
  \tkzMarkAngle[color=red,size=\SmallAngLen](O2,O1,O4)  
  \tkzLabelAngle[color=red,fill=white,pos=1](O2,O1,O4){$72$}  
           } } }

\begin{document}
\begin{tikzpicture}
\pgfmathsetlengthmacro{\Len}{5cm};
\pgfmathsetlengthmacro{\Phi}{1.6180339};
\pgfmathsetlengthmacro{\PhiLen}{\Len * \Phi }; 
\pgfmathsetlengthmacro{\OverPhiLen}{\Len / \Phi };
\pgfmathsetlengthmacro{\BigAngLen}{ \Len / \Phi }; 
\pgfmathsetlengthmacro{\SmallAngLen}{ \BigAngLen / \Phi};
\foreach \s in {0,72,144,216,288}
\draw (1,0) pic [rotate=\s] {dart};
\end{tikzpicture}
\end{document}

相关内容