6

I am trying to draw some Penrose tiling in order to learn more about tikz, and I can now make pics and place them.

But I can't label angles: if I use \tkzMarkAngle (which would be ideal) in pics, I get an error (or my pic fails if I add \usepackage{tkz-euclide})

My workaround doesn't work either: the arcs are not centered where I expected it (see image)

MWE:

\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}

enter image description here

When I really want something like this: enter image description here (a few times over)
What am I missing?

PS: While I'm at it: how do I add a label to the angles? (And yes, I will be working on the Penrose Kites soon too).

I already looked at a really nice primer

Thanks in advance, Karl

Karl
  • 63
  • If you are satisfied with at least one answer could you consider to accept it or ask for an improvement. – Tarass Apr 23 '16 at 18:54

3 Answers3

3

Do you want something like this?

fitted arcs, possibly

\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}

And here's a version which labels the angles by adding arrows and numbers. I'm not sure if these are the angles you want marked, but presumably the idea could be modified as desired. Here's the idea:

\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}

labelled angles

cfr
  • 198,882
  • It's not 144 but at least more than 180 ? ie 216. – Tarass Apr 22 '16 at 01:58
  • True, but it was only for demonstration purposes. 144 happened to be the closest number when I copied something, I think. I'm not even sure which angles are meant to be shown. – cfr Apr 22 '16 at 02:00
  • 144 is the measure of the other side of the angle. – Tarass Apr 22 '16 at 02:02
  • The OP seams to want tangent geen-red circles in his small scheme. – Tarass Apr 22 '16 at 02:18
  • Thanks. Dont really care about the colors (I understand how to change them:). I was wondering about WHY the arcs did not originate where I expected them to; now I have some reading to do. Thanks again. – Karl Apr 22 '16 at 14:30
  • @Karl I just used colours for demonstration purposes. I think you just need to trace through exactly where you're starting from. You're then saying you are at a certain point on a circle of a certain size and want to draw part of the outline of that circle. You aren't at the centre of the circle, if that makes sense. You are on its border. – cfr Apr 22 '16 at 16:40
2

enter image description here

One may change sqrt(2)-1 bye whatever between 0 and 1.

\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}
Tarass
  • 16,912
1

I don't know what you've tried with tkz-euclide, but after adding

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

\tkzMarkAngle works just fine. You had used the wrong coordinates though, so they're modified. I also changed from node to coordinate for O1 etc.

enter image description here

\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}
Torbjørn T.
  • 206,688