3

I tried this figure with tkz-euclide. enter image description here

My code

\documentclass[border=1.5mm,12pt]{standalone}
\usepackage{tkz-euclide}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\a}{3} 
\pgfmathsetmacro{\b}{5} 
\tkzDefPoints{0/0/A,\a/0/B}
\tkzInterCC[R](A,\a cm)(B,\a cm) \tkzGetFirstPoint{C}
\tkzDrawPolygon(A,B,C)
\tkzInterCC[R](C,\b cm)(B,\b cm) \tkzGetFirstPoint{X}
\tkzDefBarycentricPoint(A=1,B=1,C=1)
\tkzGetPoint{G}
\tkzDefPointBy[rotation= center G angle 120](X) 
\tkzGetPoint{Y}
\tkzDefPointBy[rotation= center G angle 240](X) 
\tkzGetPoint{Z}
\tkzDrawPoints(A,B,C,X,Y,Z)
\tkzLabelPoints[left](A)
\tkzLabelPoints[right](B,X)
\tkzLabelPoints[above](C)
\tkzLabelPoints[left](Y)
\tkzLabelPoints[below](Z)
\tkzLabelSegments[sloped](A,Z A,Y C,X B,X C,Y B,Z){\SI{\b}{cm}}
\tkzDrawSegments(A,Z B,Z B,X C,X C,Y A,Y)
\tkzLabelSegments[sloped](C,B){\SI{\a}{cm}}
\tkzLabelSegments[sloped, above](A,C){\SI{\a}{cm}}
\tkzLabelSegments(A,B){\SI{\a}{cm}}
    \end{tikzpicture}
\end{document} 
2
  • Do you mean you want to redraw the figure without loading tkz-euclide but only tikz? Jul 9, 2023 at 14:56
  • Yes. You are right Jul 9, 2023 at 14:57

4 Answers 4

6
\documentclass[tikz, border=1.5mm,12pt]{standalone}
\usetikzlibrary{intersections}

\begin{document}
\tikzset{
  % the first two styles are borrowed from my own article (in Chinese)
  % https://zhuanlan.zhihu.com/p/82427838
  dot/.style={
    circle, fill=black, inner sep=1pt, outer sep=0pt
  },
  dot label/.style={
    circle, inner sep=0pt, outer sep=1pt
  },
  midway label/.style={
    midway, sloped, below
  }
}

\begin{tikzpicture}
  \path
    (0,0) coordinate (A)
    (3,0) coordinate (B)
    (60:3) coordinate (C)
    (1.5,{.5*sqrt(3)}) coordinate (O); % center of the whole figure

  % Get coordinate X
  \path[name path=circle B] (B) circle[radius=5cm];
  \path[name path=circle C] (C) circle[radius=5cm];
  \pgfresetboundingbox % trick!
  \draw[name intersections={of=circle B and circle C}]
    (intersection-1) coordinate (X);
  
  % Get coordinates Y and Z
  \draw ([rotate around={120:(O)}]X) coordinate (Y);
  \draw ([rotate around={-120:(O)}]X) coordinate (Z);
  
  % draw segments and put midway labels
  \draw (A) -- (Z) node[midway label] {5cm}
            -- (B) node[midway label] {5cm}
            -- (A) node[midway label] {3cm};
  \draw (B) -- (X) node[midway label] {5cm}
            -- (C) node[midway label] {5cm}
            -- (B) node[midway label] {3cm};
  \draw (C) -- (Y) node[midway label] {5cm}
            -- (A) node[midway label] {5cm}
            -- (C) node[midway label, above] {3cm};

  % label coordinates
  \foreach \i/\angle in {A/180, B/0, C/90, X/0, Y/180, Z/-90} {
    \node[dot, label={[dot label]\angle:$\i$}] at (\i) {};
  }
\end{tikzpicture}
\end{document}

enter image description here

Perhaps not the simplest... I've lost familiarity with tikz tricks/conventions for some time.

Update

  • Input is "parameterized" to only depend on \shortside and \longside, with the center of figure shifted to (0, 0).
  • A general way of how to measure and store lengths of segments in macros, then convert them to target unit with desired number of places is shown, though not necessary for current figure.
    This is kind of reinventing tkz-euclide.
\documentclass[tikz, border=1.5mm, 12pt]{standalone}
\usetikzlibrary{calc, intersections}
\usepackage{siunitx}

% usage: \measureSegmentInIntegralCm{A}{B}{\lengthAB}
\newcommand\measureSegmentInIntegralCm[3]{
  \path let \p1 = ($ (#1) - (#2) $),
            \n1 = {veclen(\x1,\y1)}
        in \pgfextra
           \pgfmathsetmacro#3{\n1}\global\let#3=#3
           \endpgfextra;
  % now #3 is in pt. Convert it to cm and round to integer.
  \edef#3{\qty{\fpeval{round(\UseName{dim_to_decimal_in_cm:n}{#3 pt})}}{cm}}
}

\begin{document}
\tikzset{
  % the first two styles are borrowed from my own article (in Chinese)
  % https://zhuanlan.zhihu.com/p/82427838
  dot/.style={
    circle, fill=black, inner sep=1pt, outer sep=0pt
  },
  dot label/.style={
    circle, inner sep=0pt, outer sep=1pt
  },
  midway label/.style={
    midway, sloped, below
  }
}

\begin{tikzpicture}
  \newcommand\shortside{3}
  \newcommand\longside{5}

  % specify coordinates O, A, B, and C
  \path
    (0,0) coordinate (O) % center
    (-150:{\shortside * sqrt(3)/3}) coordinate (A)
    ([rotate around={120:(O)}]A) coordinate (B)
    ([rotate around={240:(O)}]A) coordinate (C);

  % specify coordinate X
  \path[name path=circle B] (B) circle[radius=\longside cm];
  \path[name path=circle C] (C) circle[radius=\longside cm];
  \pgfresetboundingbox % trick!
  \draw[name intersections={of=circle B and circle C}]
    (intersection-1) coordinate (X);

  % specify coordinates Y and Z
  \path
    ([rotate around={120:(O)}]X) coordinate (Y)
    ([rotate around={240:(O)}]X) coordinate (Z);

  % compute distances AB and BX in integral cm
  \measureSegmentInIntegralCm{A}{B}{\a}
  \measureSegmentInIntegralCm{B}{X}{\b}
  
  % quick way
  % \edef\a{\qty{\shortside}{cm}}
  % \edef\b{\qty{\longside}{cm}}

  % draw segments and put midway labels
  \draw (A) -- (Z) node[midway label] {\b}
            -- (B) node[midway label] {\b}
            -- (A) node[midway label] {\a};
  \draw (B) -- (X) node[midway label] {\b}
            -- (C) node[midway label] {\b}
            -- (B) node[midway label] {\a};
  \draw (C) -- (Y) node[midway label] {\b}
            -- (A) node[midway label] {\b}
            -- (C) node[midway label, above] {\a};

  % label coordinates
  \foreach \i/\angle in {A/180, B/0, C/90, X/0, Y/180, Z/-90} {
    \node[dot, label={[dot label]\angle:$\i$}] at (\i) {};
  }
\end{tikzpicture}
\end{document}
2
  • How can I avoid typing 5cm and 3 cm when I change AB and BC? In mycode, I used \pgfmathsetmacro{\a}{3} \pgfmathsetmacro{\b}{5} Jul 10, 2023 at 0:04
  • You can still use that way. I just added an updated example showing different possibilities. Jul 10, 2023 at 11:03
8

While you are waiting for Tikz-help Purely for comparison, here is a lualatex version, drawn with the built-in Metapost language.

enter image description here

You need to compile this one with lualatex.

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
numeric a, b, r, s; 
a = 3cm; b = 5cm;
r = a +-+ 1/2 a;
s = b +-+ 1/2 a;

pair A, B, C, X, Y, Z;
A = up scaled 2/3 r rotated 120;
B = A rotated 120; C = B rotated 120;

X = up scaled (1/3 r + s) rotated 300;
Y = X rotated 120; Z = Y rotated 120;

draw A -- B -- C -- cycle;
draw A -- Z -- B -- X -- C -- Y -- cycle;

dotlabel.llft("$A$", A);
dotlabel.lrt ("$B$", B);
dotlabel.top ("$C$", C);

dotlabel.urt ("$X$", X);
dotlabel.ulft("$Y$", Y);
dotlabel.bot ("$Z$", Z);

def show_size_in_cm(expr a, b) = 
  save d; numeric d; d = round(abs(a-b) / cm);
  save t; picture t; t = thelabel.top("\textsf{\scriptsize " & decimal d & "\thinspace cm}", origin);
  draw t rotated angle (b-a) shifted 1/2[a,b];
enddef;

show_size_in_cm(A, B);
show_size_in_cm(A, C);
show_size_in_cm(C, B);
show_size_in_cm(C, X);
show_size_in_cm(B, X);
show_size_in_cm(Y, A);
show_size_in_cm(Y, C);
show_size_in_cm(A, Z);
show_size_in_cm(Z, B);

endfig;
\end{mplibcode}
\end{document}
5

A more compact but not better

\documentclass[tikz]{standalone}
\usetikzlibrary {intersections}

\begin{document}

\begin{tikzpicture}

\path (0,0) coordinate(A) -- (3cm,0) coordinate(B);
\path (A) -- ++(60:3cm)coordinate(C);
\draw (A)node[left]{A} --node[midway, sloped,below]{3cm} (B)node[right]{B} -- node[midway, sloped,below]{3cm}(C)node[above]{C} 
--node[midway, sloped,below]{3cm}cycle;

\path[name path=CA] (A) circle (5cm);
\path[name path=CB] (B) circle (5cm);
\path[name path=CC] (C) circle (5cm);

\path[name intersections={of=CB and CA}] coordinate (Z) at (intersection-2);
\path[name intersections={of=CB and CC}]  coordinate (X) at (intersection-1);
\path[name intersections={of=CC and CA}]  coordinate (Y) at (intersection-1);

\draw (A) --node[midway, sloped,below]{5cm}
     (Z)node[below]{Z} 
     -- node[midway, sloped,below]{5cm}(B)
     --node[midway, sloped,below]{5cm}
     (X)node[right]{X}
     --node[midway, sloped,below]{5cm}(C)
     --node[midway, sloped,below]{5cm}
     (Y)node[left]{Y}
     --node[midway, sloped,below]{5cm}cycle;
\end{tikzpicture}


\end{document}

enter image description here

2

A direct math solution by calculating the height of the isosceles triangles. (Using the angle leads to some noticable imprecisions.)

I chose to place the annotations along the lines consistently on the outside of the figure. Even though auto is set which would solve this, the sloped options disturbs this placement again.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{quotes}
\begin{document}
\begin{tikzpicture}[
  declare function={a=3; b=5;},
  a node/.style={edge node={node[sloped,#1]{3\,cm}}},
  b node/.style={edge node={node[sloped,#1]{5\,cm}}},
  dot/.style={circle, fill, inner sep=+0pt,
    minimum size=+.4em, outer sep=+0pt, label position=center},
  node quotes mean={
    label={[dot, label={[direction shorthands,#2]{$#1$}}]center:}},
  outer/.style args={#1:#2}{
    edge node={coordinate[sloped, allow upside down, shift=(down:\height),#2](#1)}},
  auto]
\pgfmathsetmacro\height{sqrt(b*b-a*a/4)}
\draw (0,0) coordinate["A" left ] (A) to[outer=Z:"Z" below, a node=']  +(0:a)
            coordinate["B" right] (B) to[outer=X:"X" right, a node  ] +(60:a)
            coordinate["C"      ] (C) to[outer=Y:"Y" left , a node  ] cycle
                (A) to[b node='] (Z)
   to[b node='] (B) to[b node='] (X)
   to[b node  ] (C) to[b node  ] (Y)
   to[b node='] cycle;
\end{tikzpicture}
\end{document}

Output

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .