5

What is the easiest way to have TikZ or tikz-euclide generate a picture with successive incircles to a triangle without needing to calculate the points for each smaller triangle?

I have the following code that has two incircles to a triangle. What if I want to continue or automate this drawing for different triangles?

\begin{tikzpicture}

\draw ({-sqrt(3)},-1) -- ({(1-sqrt(3))/2}, {(1+sqrt(3))/2}) -- ({2+sqrt(3)},-1) -- ({-sqrt(3)},-1) ;
\draw (0,0) circle [radius=1];

\tkzDefPoint(3.7,-1){A}
\tkzDefPoint(1.16452,0.482362){B}
\tkzDefPoint(0.767327,-1){C}
\tkzDrawSegments(A,B B,C C,A)

\tkzDefCircle[in](A,B,C)\tkzGetPoint{I}\tkzGetLength{rIN}
\tkzDrawCircle[R](I,\rIN pt)

\end{tikzpicture}

Thanks!

5

I interpreted your question so that the new triangles are similar to the old one. Your example was different in that point.

With a little work, you can create an image that has that recursive done at every side and also in the circle itself.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{calc,through}
\makeatletter
\pgfmathdeclarefunction{tikzveclen}{2}{%
  \begingroup
%    \pgfpointdiff{\tikz@scan@one@point\pgfutil@firstofone(#1)}
%                 {\tikz@scan@one@point\pgfutil@firstofone(#2)}%
    \pgfpointdiff{\pgfpointanchor{#1}{center}}{\pgfpointanchor{#2}{center}}%
    \edef\pgfmath@temp{{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}}%
    \expandafter\pgfmathveclen@\pgfmath@temp
    \pgfmath@smuggleone\pgfmathresult
  \endgroup}
\makeatother
\begin{document}
\begin{tikzpicture}[scale=4]
\path (0,0) coordinate (A) + (0:3) coordinate (B) +(60:1) coordinate (C);
\draw (A) -- (B) -- (C) -- cycle;
\foreach \cnt in {1,...,10}{
  \pgfmathsetmacro\triA{tikzveclen("B","C")}
  \pgfmathsetmacro\triB{tikzveclen("C","A")}
  \pgfmathsetmacro\triC{tikzveclen("A","B")}
 %\pgfmathsetmacro\triS{.5*\triA+.5*\triB+.5*\triC}
 %\pgfmathsetlengthmacro\triRadius{sqrt((\triS-\triA)/\triS*(\triS-\triB)*(\triS-\triC))}
  \path (barycentric cs:A=\triA,B=\triB,C=\triC) coordinate (M)
       node [draw, circle through=($(A)!(M)!(C)$)] (M) {};
 % or: circle[radius=\triRadius]
  \draw ($(C)-(A)$) coordinate (vecB)
      (M.60-90) coordinate (@) % or: ([shift=(60-90:\triRadius)] M) coordinate (@)
      (intersection of @--[shift=(vecB)]@ and B--C) coordinate (C) -- 
      (intersection of @--[shift=(vecB)]@ and B--A) coordinate (A);
}
\end{tikzpicture}
\end{document}

Output

enter image description here

  • This is fantastic! Thank you! What if I wanted to have all the triangles similar except for the largest one? Is there an easy way to do that? – David Caliri Nov 27 '13 at 21:05
  • 1
    @DavidCaliri Well, then just do the first, non-regular step separately and enter the pseudo-recursive algorithm/the foreach loop after that. – Qrrbrbirlbel Nov 28 '13 at 1:00
  • That worked great! Thank you! I also worked it to get the circles going down each corner of the triangle, but I'm not sure if I did this in the most efficient way. I apologize I am new to this site and not sure how I should post the new code. In a new question, or an answer to this question? – David Caliri Dec 1 '13 at 22:39
7

With math library (cvs-version) it's easy:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{math}
\begin{document}
\begin{tikzpicture}

\foreach \i [remember=\r (initially 3)] in {1,2,...,5}{
   \draw (0,0) circle (\r);
   \draw (90:\r) -- (-30:\r)--(210:\r)--cycle;
   \tikzmath{
      \r=\r*sin(30);
   }
}
\end{tikzpicture}
\end{document}

enter image description here

EDIT

And this is a valid solution for TiKZ 2.10. It uses through library.

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{through}
\begin{document}
\begin{tikzpicture}
   \draw (0,0) circle (3cm);
   \coordinate (a) at (90:3);
   \coordinate (b) at (-30:3);
   \coordinate (c) at (210:3);
   \foreach \in in {1,2,...,5}
   {
     \node[circle through=(a),draw] {};
     \draw (a)--(b)--(c)--cycle;
     \coordinate(aux) at (a);
     \path (a)--(b) coordinate[pos=.5] (a);
     \path (b)--(c) coordinate[pos=.5] (b);
     \path (c)--(aux) coordinate[pos=.5] (c);
   }
\end{tikzpicture}

\end{document}

enter image description here

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.