# How to draw an equilateral triangle with TikZ?

I'm trying to draw a little picture with TikZ. It should show an equilateral triangle with length 1 and circles with radius 1/2 on each corner of the triangle. Next, the intersections of the circles should be highlighted with a dot. This is what I tried so far:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}
\begin{tikzpicture}[scale=1.5]
\coordinate (a) at (0,0);
\coordinate (b) at (1,0);
\coordinate (c) at (0.5,0.866);

\draw[dashed] (a)--(b)--(c)--(a);
\draw[name path=circleA] (a) circle (0.5);
\draw[name path=circleB] (b) circle (0.5);
\draw[name path=circleC] (c) circle (0.5);

\fill (0.5,0) circle (1pt);
\path [name intersections={of=circleA and circleC,name=AC}];
\fill (AC-1) circle (1pt);
\path[name intersections={of=circleB and circleC,name=BC}];
\fill (BC-1) circle (1pt);
\end{tikzpicture}
\end{document} As one can see, the intersections aren't placed exactly where they should be, because the triangle isn't perfectly equilateral. How can I do that?

• Try \coordinate (c) at (60:1); for coordinate c. Then the rest should work out by itself ;-) Apr 5, 2015 at 18:57

Intersection computations rely on numerically sensitive mechanisms and it does not always give you the precision you are looking for especially if tangents are in question (they get very close and might trigger and early/late true signal). But since the problem is relatively easy geometrically you can get away with many options. Here is another one

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[dashed](0,0) coordinate (a)--+(1,0) coordinate (b)--+(60:1) coordinate (c) --cycle;
\foreach\x[remember=\x as \lastx (initially c)] in{a,b,c}{
\node[fill,circle,inner sep=1pt] at($(\x)!0.5!(\lastx)$)  (\x-\lastx) {};
\draw (\x)circle (0.5);
}
\end{tikzpicture}
\end{document} • @Jeroen: Note the cycle , which gives a better corner. Apr 5, 2015 at 19:39
• @percusse: Is it necessary (\x-\lastx)? Great answer Apr 5, 2015 at 20:34
• @jpayansomet Thank you. I don't think so but I couldn't think of something else to, both, stay in the loop and find the midpoints. So I cooked this up. But I'm not really bright on Sunday evenings hence please let me know if I'm missing the obvious. Apr 5, 2015 at 20:36
• @jpayansomet Ah you mean the node names... Yes the question owner said they have to be referenced but after the edit it is gone... See I'm not that bright hahaha Apr 5, 2015 at 20:55
• @percusse: You're right. In my original question, I asked for the nodes to be named, but afterwards, I realised that I don't specifically use the intersections in my text, so it seemed a bit redundant to name them. Apr 6, 2015 at 14:21

Not sure this is the best way, but... \documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{shapes.geometric,calc,through}
\begin{document}
\begin{tikzpicture}
\node (tri) [regular polygon, regular polygon sides=3, draw, densely dashed, minimum width=50mm] {};
\foreach \i/\j in {1/2,2/3,3/1}
{
\node [draw] at (tri.corner \i) [circle through={($(tri.corner \i)!1/2!(tri.corner \j)$)}, draw] {};
\path [fill] ($(tri.corner \i)!1/2!(tri.corner \j)$) circle (2.5pt);
}
\end{tikzpicture}
\end{document}


With tkz-euclide (made more verbose for clarity)

\documentclass[border=5mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[scale=.8]
\tkzDefPoint(0,0){A}
\tkzDefPoint(5,0){B}
\tkzDefEquilateral(A,B)\tkzGetPoint{C}
\tkzDrawPolygon[color=magenta,dashed](A,B,C)
\tkzDefMidPoint(A,B) \tkzGetPoint{D}
\tkzDefMidPoint(B,C) \tkzGetPoint{E}
\tkzDefMidPoint(A,C) \tkzGetPoint{F}
\tkzDrawCircle(A,D)
\tkzDrawCircle(B,E)
\tkzDrawCircle(C,F)
\tkzDrawPoints[size=12,fill=green](D,E,F)
%\tkzCentroid(A,B,C)\tkzGetPoint{G}
%\tkzDrawPoint(G)
%\tkzDrawLines[add = 0 and 2/3](A,G B,G C,G)
\end{tikzpicture}
\end{document} One way among others of solving this, with MetaPost for whom it may interest. The equilateral triangle is built by rotating a unit side by 60°, and the intersections are found using the intersectionpoint operator. It is interesting to notice that this operator fails with MetaPost's default fixed-point arithmetic. Only after switching to floating-point numerics (\mplibnumbersystem{double}) it is able to find the intersection points.

\documentclass[border=2bp]{standalone}
\usepackage{luamplib}
\mplibnumbersystem{double}
\begin{document}
\begin{mplibcode}
numeric u; u = 5cm; path circle[];
beginfig(1);
z1 = origin; z2 = (u, 0); z3 = z2 rotatedaround (z1, 60);
draw z1 -- z2 -- z3 -- cycle dashed evenly;
for i= 1, 2, 3:
circle[i] = fullcircle scaled u shifted z[i];
draw circle[i];
endfor;
z12 = circle1 intersectionpoint circle2;
z13 = circle1 intersectionpoint circle3;
z23 = circle2 intersectionpoint circle3;
for i = 12, 13, 23:
drawdot z[i] withpen pencircle scaled 5bp;
endfor
endfig;
\end{mplibcode}
\end{document}


To be typeset with LuaLaTeX. Output: • You can make this work with the default number system, if you find the intersections before you scale them up. But it won't be very accurate. Then again, you really don't need to use intersectionpoint here - all you need is z12 = .5[z1,z2] etc. Apr 6, 2015 at 22:50
• @Thruston I knew that, like everybody else here. But computing the intersections was part of the game. Thanks for the remark about the scaling. Previously I noticed (for a different problem) that the linear equation solver also could fail after scaling and succeed before. Apr 6, 2015 at 23:11
• Yes sure, and the discussion reveals that MP's intersection algorithm is not optimized for find the tangent points of two circles (which is not surprising since it's always the midpoint of the two centres). It's interesting to find out that the intersections work better with the new number system - but that may just be an accident of the way they are implemented. Apr 6, 2015 at 23:15