4

I am attempting to plot an Pinwheel Triangle (see pinwheel tiling) recursively onto itself, in order to have something that looks approximately like this:

A pinwheel triangle that is plotted recursively onto itself

This is generated using the following code:

\begin{figure}[H]
    \centering
    \begin{tikzpicture}[scale=5]
        \coordinate [label=above: $A_{0}$] (A_0) at (0,1);
        \coordinate [label=below: $B_{0}$] (B_0) at (0,0);
        \coordinate [label=right: $C_{0}$] (C_0) at (2,0);
        \draw (A_0) -- (B_0) -- (C_0) -- (A_0);

        \coordinate [label=above: $A_{1}$]
        (A_1) at ($(A_0)!(B_0)!(C_0)$);
        \coordinate [label=below: $C_{1}$]
        (C_1) at ($(B_0)!0.5!(C_0)$);
        \coordinate [label=above: $H_{0}$]
        (H_0) at ($(A_0)!(C_1)!(C_0)$);
        \coordinate [label=left: $B_{1}$]
        (B_1) at ($(A_1)!(C_1)!(B_0)$);
        \coordinate [label=above: $A_{2}$]
        (A_2) at ($(A_1)!(B_1)!(C_1)$);
        \coordinate [label=below: $C_{2}$]
        (C_2) at ($(B_1)!0.5!(C_1)$);
        \coordinate [label=above: $H_{1}$]
        (H_1) at ($(A_1)!(C_2)!(C_1)$);
        \coordinate [label=left: $B_{2}$]
        (B_2) at ($(A_2)!(C_2)!(B_1)$);

        \coordinate (A_3) at ($(A_2)!(B_2)!(C_2)$);
        \coordinate (C_3) at ($(B_2)! 0.5 !(C_2)$);
        \coordinate (H_2) at ($(A_2)!(C_3)!(C_2)$);
        \coordinate (B_3) at ($(A_3)!(C_3)!(B_2)$);
        \coordinate (A_4) at ($(A_3)!(B_3)!(C_3)$);
        \coordinate (C_4) at ($(B_3)! 0.5 !(C_3)$);
        \coordinate (H_3) at ($(A_3)!(C_4)!(C_3)$);
        \coordinate (B_4) at ($(A_4)!(C_4)!(B_3)$);
        \coordinate (A_5) at ($(A_4)!(B_4)!(C_4)$);
        \coordinate (C_5) at ($(B_4)! 0.5 !(C_4)$);
        \coordinate (H_4) at ($(A_4)!(C_5)!(C_4)$);
        \coordinate (B_5) at ($(A_5)!(C_5)!(B_4)$);
        \coordinate (A_6) at ($(A_5)!(B_5)!(C_5)$);
        \coordinate (C_6) at ($(B_5)! 0.5 !(C_5)$);
        \coordinate (H_5) at ($(A_5)!(C_6)!(C_5)$);
        \coordinate (B_6) at ($(A_6)!(C_6)!(B_5)$);
        \coordinate (A_7) at ($(A_6)!(B_6)!(C_6)$);
        \coordinate (C_7) at ($(B_6)! 0.5 !(C_6)$);
        \coordinate (H_6) at ($(A_6)!(C_7)!(C_6)$);
        \coordinate (B_7) at ($(A_7)!(C_7)!(B_6)$);
        \coordinate (A_8) at ($(A_7)!(B_7)!(C_7)$);
        \coordinate (C_8) at ($(B_7)! 0.5 !(C_7)$);
        \coordinate (H_7) at ($(A_7)!(C_8)!(C_7)$);
        \coordinate (B_8) at ($(A_8)!(C_8)!(B_7)$);
        \coordinate (A_9) at ($(A_8)!(B_8)!(C_8)$);
        \coordinate (C_9) at ($(B_8)! 0.5 !(C_8)$);
        \coordinate (H_8) at ($(A_8)!(C_9)!(C_8)$);
        \coordinate (B_9) at ($(A_9)!(C_9)!(B_8)$);

        \draw (A_1) -- (B_0);
        \draw (C_1) -- (H_0);
        \draw (B_1) -- (C_1);
        \draw (A_1) -- (C_1);
        \draw (A_2) -- (B_1);
        \draw (C_2) -- (H_1);
        \draw (B_2) -- (C_2);
        \draw (A_2) -- (C_2);
        \draw (A_3) -- (B_2);
        \draw (C_3) -- (H_2);
        \draw (B_3) -- (C_3);
        \draw (A_3) -- (C_3);
        \draw (A_4) -- (B_3);
        \draw (C_4) -- (H_3);
        \draw (B_4) -- (C_4);
        \draw (A_4) -- (C_4);
        \draw (A_5) -- (B_4);
        \draw (C_5) -- (H_4);
        \draw (B_5) -- (C_5);
        \draw (A_5) -- (C_5);
        \draw (A_6) -- (B_5);
        \draw (C_6) -- (H_5);
        \draw (B_6) -- (C_6);
        \draw (A_6) -- (C_6);
        \draw (A_7) -- (B_6);
        \draw (C_7) -- (H_6);
        \draw (B_7) -- (C_7);
        \draw (A_7) -- (C_7);
        \draw (A_8) -- (B_7);
        \draw (C_8) -- (H_7);
        \draw (B_8) -- (C_8);
        \draw (A_8) -- (C_8);
        \draw (A_9) -- (B_8);
        \draw (C_9) -- (H_8);
        \draw (B_9) -- (C_9);
        \draw (A_9) -- (C_9);

    \end{tikzpicture}
    \label{pinwheel-triangle-infinite}
\end{figure}

I would like to zoom in on the details, and appreciate the structure of the pinwheel tiling at greater magnification. So I used the standalone format, in order to generate a copy of the triangle at an larger scale. I used the following code:

\documentclass[11pt]{standalone}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
% The coordinate math engine in tikz has an error that makes it inaccurate at
% calculating extremely fine coordinates. This redefinition fixes the problem:
% https://tex.stackexchange.com/questions/256333/256377
% use the Mark Wibrow's correction
\makeatletter
\def\pgfpointnormalised#1{%
  \pgf@process{#1}%
  \pgfmathatantwo{\the\pgf@y}{\the\pgf@x}%
  \let\pgf@tmp=\pgfmathresult%
  \pgfmathcos@{\pgf@tmp}\pgf@x=\pgfmathresult pt\relax%
  \pgfmathsin@{\pgf@tmp}\pgf@y=\pgfmathresult pt\relax%
}

\begin{document}
\begin{figure}[h]
    \centering
    \begin{tikzpicture}[rotate=90, scale=30]
        \coordinate [label=above: $A_{0}$] (A_0) at (0,1);
        \coordinate [label=below: $B_{0}$] (B_0) at (0,0);
        \coordinate [label=right: $C_{0}$] (C_0) at (2,0);
        \draw (A_0) -- (B_0) -- (C_0) -- (A_0);
        \coordinate [label=above: $A_{1}$]
        (A_1) at ($(A_0)!(B_0)!(C_0)$);
        \coordinate [label=below: $C_{1}$]
        (C_1) at ($(B_0)!0.5!(C_0)$);
        \coordinate [label=above: $H_{0}$]
        (H_0) at ($(A_0)!(C_1)!(C_0)$);
        \coordinate [label=left: $B_{1}$]
        (B_1) at ($(A_1)!(C_1)!(B_0)$);
        \coordinate [label=above: $A_{2}$]
        (A_2) at ($(A_1)!(B_1)!(C_1)$);
        \coordinate [label=below: $C_{2}$]
        (C_2) at ($(B_1)!0.5!(C_1)$);
        \coordinate [label=above: $H_{1}$]
        (H_1) at ($(A_1)!(C_2)!(C_1)$);
        \coordinate [label=left: $B_{2}$]
        (B_2) at ($(A_2)!(C_2)!(B_1)$);
        \coordinate (A_3) at ($(A_2)!(B_2)!(C_2)$);
        \coordinate (C_3) at ($(B_2)! 0.5 !(C_2)$);
        \coordinate (H_2) at ($(A_2)!(C_3)!(C_2)$);
        \coordinate (B_3) at ($(A_3)!(C_3)!(B_2)$);
        \coordinate (A_4) at ($(A_3)!(B_3)!(C_3)$);
        \coordinate (C_4) at ($(B_3)! 0.5 !(C_3)$);
        \coordinate (H_3) at ($(A_3)!(C_4)!(C_3)$);
        \coordinate (B_4) at ($(A_4)!(C_4)!(B_3)$);
        \coordinate (A_5) at ($(A_4)!(B_4)!(C_4)$);
        \coordinate (C_5) at ($(B_4)! 0.5 !(C_4)$);
        \coordinate (H_4) at ($(A_4)!(C_5)!(C_4)$);
        \coordinate (B_5) at ($(A_5)!(C_5)!(B_4)$);
        \coordinate (A_6) at ($(A_5)!(B_5)!(C_5)$);
        \coordinate (C_6) at ($(B_5)! 0.5 !(C_5)$);
        \coordinate (H_5) at ($(A_5)!(C_6)!(C_5)$);
        \coordinate (B_6) at ($(A_6)!(C_6)!(B_5)$);
        \coordinate (A_7) at ($(A_6)!(B_6)!(C_6)$);
        \coordinate (C_7) at ($(B_6)! 0.5 !(C_6)$);
        \coordinate (H_6) at ($(A_6)!(C_7)!(C_6)$);
        \coordinate (B_7) at ($(A_7)!(C_7)!(B_6)$);
        \coordinate (A_8) at ($(A_7)!(B_7)!(C_7)$);
        \coordinate (C_8) at ($(B_7)! 0.5 !(C_7)$);
        \coordinate (H_7) at ($(A_7)!(C_8)!(C_7)$);
        \coordinate (B_8) at ($(A_8)!(C_8)!(B_7)$);
        \coordinate (A_9) at ($(A_8)!(B_8)!(C_8)$);
        \coordinate (C_9) at ($(B_8)! 0.5 !(C_8)$);
        \coordinate (H_8) at ($(A_8)!(C_9)!(C_8)$);
        \coordinate (B_9) at ($(A_9)!(C_9)!(B_8)$);
        \draw[thin] (A_1) -- (B_0);
        \draw[thin] (C_1) -- (H_0);
        \draw[thin] (B_1) -- (C_1);
        \draw[thin] (A_1) -- (C_1);
        \draw[thin] (A_2) -- (B_1);
        \draw[thin] (C_2) -- (H_1);
        \draw[thin] (B_2) -- (C_2);
        \draw[thin] (A_2) -- (C_2);
        \draw[thin] (A_3) -- (B_2);
        \draw[thin] (C_3) -- (H_2);
        \draw[thin] (B_3) -- (C_3);
        \draw[thin] (A_3) -- (C_3);
        \draw[thin] (A_4) -- (B_3);
        \draw[thin] (C_4) -- (H_3);
        \draw[thin] (B_4) -- (C_4);
        \draw[thin] (A_4) -- (C_4);
        \draw[thin] (A_5) -- (B_4);
        \draw[thin] (C_5) -- (H_4);
        \draw[thin] (B_5) -- (C_5);
        \draw[thin] (A_5) -- (C_5);
        \draw[thin] (A_6) -- (B_5);
        \draw[thin] (C_6) -- (H_5);
        \draw[thin] (B_6) -- (C_6);
        \draw[thin] (A_6) -- (C_6);
        \draw[thin] (A_7) -- (B_6);
        \draw[thin] (C_7) -- (H_6);
        \draw[thin] (B_7) -- (C_7);
        \draw[thin] (A_7) -- (C_7);
        \draw[thin] (A_8) -- (B_7);
        \draw[thin] (C_8) -- (H_7);
        \draw[thin] (B_8) -- (C_8);
        \draw[thin] (A_8) -- (C_8);
        \draw[thin] (A_9) -- (B_8);
        \draw[thin] (C_9) -- (H_8);
        \draw[thin] (B_9) -- (C_9);
        \draw[thin] (A_9) -- (C_9);
    \end{tikzpicture}
\end{figure}
\end{document}

However, due to some sort of floating-point calculation issue with TiKZ's coordinate math engine, it appears that errors are building up and ruining the diagram. rather than having a beautiful pinwheel diagram, I end up with some sort of an half-hearted squiggle.

An ugly, badly plotted squiggle

Please note that even when I apply Mark Wibrow's fix, the problem is not resolved. It appears this issue is influenced by the scaling factor. The image above is plotted with a scale of 30. If I increase to 50, it's even worse.

Thank you for your time and consideration. I would love to find a solution to this problem.

P.S: I understand that my code utilizes multiple coordinate calculations. If there's some way to optimize it (perhaps a loop?) to use less coordinate calculations, that would also be fine.

6

The basic idea here, is not to use the coordinate projection stuff, but simply get the points by interpolation and then use recursion and transformations ad nausium. It results in much shorter code:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{calc}
\pgfmathparse{1/sqrt(5)}\let\k=\pgfmathresult
\pgfmathparse{asin(\k)}\let\b=\pgfmathresult
\newcommand\pinwheel[2][]{\begin{scope}[#1]\PinWheel{0}{#2}\end{scope}}
\def\PinWheel#1#2{%
\pgfmathparse{int(#1)}\let\pw=\pgfmathresult%
\pgfmathparse{sqrt(1/(\pw + 1)}\let\sc=\pgfmathresult
\path 
  (0, 1) coordinate (A) node [scale=\sc, anchor=270-\b*\pw] {$A_\pw$}
  (0, 0) coordinate (B) node [scale=\sc, anchor= 45-\b*\pw] {$B_\pw$}
  (2, 0) coordinate (C) node [scale=\sc, anchor=180-\b*\pw] {$C_\pw$};
\draw (A) -- (B) -- (C) -- cycle;
\ifnum\pw<#2
\path
  ($(A)!0.2!(C)$) coordinate (P) ($(B)!0.5!(P)$) coordinate (Q)
  ($(P)!0.5!(C)$) coordinate (R) ($(B)!0.5!(C)$) coordinate (S);
\draw (B) -- (Q) (S) -- (R) node [scale=\sc, anchor=225-\b*\pw] {$H_\pw$};
\begin{scope}[shift=(Q), scale=\k, rotate=-\b]
  \PinWheel{\pw+1}{#2}
\end{scope}
\fi}
\begin{document}
\begin{tikzpicture}[line join=round]
\pinwheel[scale=3]{3}
\end{tikzpicture}
\end{document}

enter image description here

But, if you want a pretty picture using broadly the same principles:

\documentclass[varwidth,border=5]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\pgfmathparse{1/sqrt(5)}\let\k=\pgfmathresult
\pgfmathparse{acos(\k)}\let\a=\pgfmathresult
\pgfmathparse{asin(\k)}\let\b=\pgfmathresult
\newcount\pinwheelorder
\def\pinwheel#1{%
\begin{scope}
\pgfmathsetcount\pinwheelorder{#1}%
\edef\order{\the\pinwheelorder}
\path
  ($(0,1)!0.2!(2,0)$) coordinate (P-\order)
  ($(0,0)!0.5!(P-\order)$)   coordinate (Q-\order)
  ($(P-\order)!0.5!(2,0)$)   coordinate (R-\order);
\begin{scope}[shift=(P-\order), scale=\k, xscale=-1, rotate=-\a]
  \path [every triangle/.try, triangle 1/.try] (0,0) -- (0,1) -- (2,0) -- cycle;
  \ifnum\pinwheelorder>0
    \pinwheel{\pinwheelorder-1}
  \fi
\end{scope}
\begin{scope}[shift=(Q-\order), scale=\k, xscale=-1, rotate=270-\a] 
  \path [every triangle/.try, triangle 2/.try] (0,0) -- (0,1) -- (2,0) -- cycle; 
  \ifnum\pinwheelorder>0
    \pinwheel{\pinwheelorder-1}
  \fi
\end{scope}
\begin{scope}[shift=(Q-\order), scale=\k, rotate=-\b]
  \path [every triangle/.try, triangle 3/.try] (0,0) -- (0,1) -- (2,0) -- cycle;
  \ifnum\pinwheelorder>0
    \pinwheel{\pinwheelorder-1}
  \fi
\end{scope}
\begin{scope}[shift=(R-\order), scale=\k, rotate=180-\b]
  \path [every triangle/.try, triangle 4/.try] (0,0) -- (0,1) -- (2,0) -- cycle;
  \ifnum\pinwheelorder>0
    \pinwheel{\pinwheelorder-1}
  \fi
\end{scope}
\begin{scope}[shift=(R-\order), scale=\k, xscale=-1, rotate=270-\a]
  \path [every triangle/.try, triangle 5/.try] (0,0) -- (0,1) -- (2,0) -- cycle;
  \ifnum\pinwheelorder>0
    \pinwheel{\pinwheelorder-1}
  \fi
\end{scope}
\end{scope}
}
\tikzset{
  every triangle/.style={draw=white, thick, line join=round},
  triangle 1/.style={fill=red},
  triangle 2/.style={fill=orange},
  triangle 3/.style={fill=yellow},
  triangle 4/.style={fill=purple},
  triangle 5/.style={fill=pink}}
\begin{document}
\tikz[scale=5]{\pinwheel{0}}
\tikz[scale=5]{\pinwheel{1}}
\tikz[scale=5]{\pinwheel{2}}
\tikz[scale=5]{\pinwheel{3}}
\end{document}

enter image description here

  • With this proposition, the initial shape of the triangle is hard coded: if you change the position of C to (1.3,0) (for example), you have to change the interpolation factor... – Paul Gaborit Feb 1 '18 at 14:31
2

My advice: do not use the scale option or only when it is absolutely necessary. In your code, the scale option is useful only to define A_0, B_0 and C_0.

\documentclass[11pt]{standalone}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
% The coordinate math engine in tikz has an error that makes it inaccurate at
% calculating extremely fine coordinates. This redefinition fixes the problem:
% https://tex.stackexchange.com/questions/256333/256377
% use the Mark Wibrow's correction
\makeatletter
\def\pgfpointnormalised#1{%
  \pgf@process{#1}%
  \pgfmathatantwo{\the\pgf@y}{\the\pgf@x}%
  \let\pgf@tmp=\pgfmathresult%
  \pgfmathcos@{\pgf@tmp}\pgf@x=\pgfmathresult pt\relax%
  \pgfmathsin@{\pgf@tmp}\pgf@y=\pgfmathresult pt\relax%
}
\makeatother

\begin{document}
\begin{tikzpicture}[rotate=90]
  \begin{scope}[scale=30]
    \coordinate [label=above: $A_{0}$] (A_0) at (0,1);
    \coordinate [label=below: $B_{0}$] (B_0) at (0,0);
    \coordinate [label=right: $C_{0}$] (C_0) at (2,0);
  \end{scope}
  \draw (A_0) -- (B_0) -- (C_0) -- (A_0);
  \coordinate [label=above: $A_{1}$]
  (A_1) at ($(A_0)!(B_0)!(C_0)$);
  \coordinate [label=below: $C_{1}$]
  (C_1) at ($(B_0)!0.5!(C_0)$);
  \coordinate [label=above: $H_{0}$]
  (H_0) at ($(A_0)!(C_1)!(C_0)$);
  \coordinate [label=left: $B_{1}$]
  (B_1) at ($(A_1)!(C_1)!(B_0)$);
  \coordinate [label=above: $A_{2}$]
  (A_2) at ($(A_1)!(B_1)!(C_1)$);
  \coordinate [label=below: $C_{2}$]
  (C_2) at ($(B_1)!0.5!(C_1)$);
  \coordinate [label=above: $H_{1}$]
  (H_1) at ($(A_1)!(C_2)!(C_1)$);
  \coordinate [label=left: $B_{2}$]
  (B_2) at ($(A_2)!(C_2)!(B_1)$);
  \coordinate (A_3) at ($(A_2)!(B_2)!(C_2)$);
  \coordinate (C_3) at ($(B_2)! 0.5 !(C_2)$);
  \coordinate (H_2) at ($(A_2)!(C_3)!(C_2)$);
  \coordinate (B_3) at ($(A_3)!(C_3)!(B_2)$);
  \coordinate (A_4) at ($(A_3)!(B_3)!(C_3)$);
  \coordinate (C_4) at ($(B_3)! 0.5 !(C_3)$);
  \coordinate (H_3) at ($(A_3)!(C_4)!(C_3)$);
  \coordinate (B_4) at ($(A_4)!(C_4)!(B_3)$);
  \coordinate (A_5) at ($(A_4)!(B_4)!(C_4)$);
  \coordinate (C_5) at ($(B_4)! 0.5 !(C_4)$);
  \coordinate (H_4) at ($(A_4)!(C_5)!(C_4)$);
  \coordinate (B_5) at ($(A_5)!(C_5)!(B_4)$);
  \coordinate (A_6) at ($(A_5)!(B_5)!(C_5)$);
  \coordinate (C_6) at ($(B_5)! 0.5 !(C_5)$);
  \coordinate (H_5) at ($(A_5)!(C_6)!(C_5)$);
  \coordinate (B_6) at ($(A_6)!(C_6)!(B_5)$);
  \coordinate (A_7) at ($(A_6)!(B_6)!(C_6)$);
  \coordinate (C_7) at ($(B_6)! 0.5 !(C_6)$);
  \coordinate (H_6) at ($(A_6)!(C_7)!(C_6)$);
  \coordinate (B_7) at ($(A_7)!(C_7)!(B_6)$);
  \coordinate (A_8) at ($(A_7)!(B_7)!(C_7)$);
  \coordinate (C_8) at ($(B_7)! 0.5 !(C_7)$);
  \coordinate (H_7) at ($(A_7)!(C_8)!(C_7)$);
  \coordinate (B_8) at ($(A_8)!(C_8)!(B_7)$);
  \coordinate (A_9) at ($(A_8)!(B_8)!(C_8)$);
  \coordinate (C_9) at ($(B_8)! 0.5 !(C_8)$);
  \coordinate (H_8) at ($(A_8)!(C_9)!(C_8)$);
  \coordinate (B_9) at ($(A_9)!(C_9)!(B_8)$);
  \draw[thin] (A_1) -- (B_0);
  \draw[thin] (C_1) -- (H_0);
  \draw[thin] (B_1) -- (C_1);
  \draw[thin] (A_1) -- (C_1);
  \draw[thin] (A_2) -- (B_1);
  \draw[thin] (C_2) -- (H_1);
  \draw[thin] (B_2) -- (C_2);
  \draw[thin] (A_2) -- (C_2);
  \draw[thin] (A_3) -- (B_2);
  \draw[thin] (C_3) -- (H_2);
  \draw[thin] (B_3) -- (C_3);
  \draw[thin] (A_3) -- (C_3);
  \draw[thin] (A_4) -- (B_3);
  \draw[thin] (C_4) -- (H_3);
  \draw[thin] (B_4) -- (C_4);
  \draw[thin] (A_4) -- (C_4);
  \draw[thin] (A_5) -- (B_4);
  \draw[thin] (C_5) -- (H_4);
  \draw[thin] (B_5) -- (C_5);
  \draw[thin] (A_5) -- (C_5);
  \draw[thin] (A_6) -- (B_5);
  \draw[thin] (C_6) -- (H_5);
  \draw[thin] (B_6) -- (C_6);
  \draw[thin] (A_6) -- (C_6);
  \draw[thin] (A_7) -- (B_6);
  \draw[thin] (C_7) -- (H_6);
  \draw[thin] (B_7) -- (C_7);
  \draw[thin] (A_7) -- (C_7);
  \draw[thin] (A_8) -- (B_7);
  \draw[thin] (C_8) -- (H_7);
  \draw[thin] (B_8) -- (C_8);
  \draw[thin] (A_8) -- (C_8);
  \draw[thin] (A_9) -- (B_8);
  \draw[thin] (C_9) -- (H_8);
  \draw[thin] (B_9) -- (C_9);
  \draw[thin] (A_9) -- (C_9);
\end{tikzpicture}
\end{document}

enter image description here

Here a solution with \foreach to shorten the code (same result as above, except the labels):

\documentclass[11pt,tikz]{standalone}
\usetikzlibrary{calc}
% The coordinate math engine in tikz has an error that makes it inaccurate at
% calculating extremely fine coordinates. This redefinition fixes the problem:
% https://tex.stackexchange.com/questions/256333/256377
% use the Mark Wibrow's correction
\makeatletter
\def\pgfpointnormalised#1{%
  \pgf@process{#1}%
  \pgfmathatantwo{\the\pgf@y}{\the\pgf@x}%
  \let\pgf@tmp=\pgfmathresult%
  \pgfmathcos@{\pgf@tmp}\pgf@x=\pgfmathresult pt\relax%
  \pgfmathsin@{\pgf@tmp}\pgf@y=\pgfmathresult pt\relax%
}
\makeatother

\begin{document}
\begin{tikzpicture}[rotate=90,line join=round]
  \begin{scope}[scale=30]
    \coordinate [label=above: $A_{0}$] (A-0) at (0,1);
    \coordinate [label=below: $B_{0}$] (B-0) at (0,0);
    \coordinate [label=right: $C_{0}$] (C-0) at (2,0);
  \end{scope}
  \draw (A-0) -- (B-0) -- (C-0) -- (A-0);

  \foreach \lev in {1,...,9}{
    \pgfmathsetmacro{\plev}{int(\lev-1)}
    \coordinate (A-\lev) at ($(A-\plev)!(B-\plev)!(C-\plev)$);
    \coordinate (C-\lev) at ($(B-\plev)!.5!(C-\plev)$);
    \coordinate (H-\plev) at ($(A-\plev)!(C-\lev)!(C-\plev)$);
    \coordinate (B-\lev) at ($(A-\lev)!(C-\lev)!(B-\plev)$);
    \draw[thin] (A-\lev) -- (B-\plev);
    \draw[thin] (C-\lev) -- (H-\plev);
    \draw[thin] (A-\lev) -- (B-\lev) -- (C-\lev) -- cycle;
  }
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.