7

I want to draw a triangle circle is insribed in a circle so that the vertices divide the circle into three arcs of lengths 3, 4 and 5. I tried with Geogebra.

\documentclass[12pt]{standalone}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-0.5,-0.5) rectangle (4.5,4.298548095909735);
\draw(2.,2.) circle (2.cm);
\draw (0.64845913365678,3.4742242999639563)-- (0.5257757000360437,0.64845913365678);
\draw (0.5257757000360437,0.64845913365678)-- (3.907580874488035,1.3990547385264929);
\draw (3.907580874488035,1.3990547385264929)-- (0.64845913365678,3.4742242999639563);
\draw (-0.4,2.1844051666973288) node[anchor=north west] {3};
\draw (2.0939306358381504,0) node[anchor=north west] {4};
\draw (3,4.2) node[anchor=north west] {5};
\draw [fill=black] (2.,2.) circle (1.5pt);
\draw[color=black] (2,1.6) node {$I$};
\draw [fill=black] (0.64845913365678,3.4742242999639563) circle (1.5pt);
\draw[color=black] (0.6,3.8) node {$A$};
\draw [fill=black] (0.5257757000360437,0.64845913365678) circle (1.5pt);
\draw[color=black] (0.49,0.2) node {$B$};
\draw [fill=black] (3.907580874488035,1.3990547385264929) circle (1.5pt);
\draw[color=black] (4.15,1.377692733182069) node {$C$};
\end{tikzpicture}
\end{document}

enter image description here

How can I draw that picture by using tikz (or pstricks) with nice code?

1
  • Why do you don't use the geogebra PDF output directly?
    – wipet
    Apr 8, 2015 at 16:40

6 Answers 6

6

Define a circle with 3+4+5=12 degrees:

\documentclass[pstricks]{standalone}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
\degrees[12]
\pspolygon[showpoints](2;1)(2;4)(2;8)
\pscircle[showpoints](0,0){2}
\uput[1](2;1){A}\uput[4](2;4){B}\uput[8](2;8){C}
\rput(1.7;2.5){3}\rput(1.5;6){4}\rput(1.25;11){5}
\end{pspicture}
\end{document}

enter image description here

6

You can decorate the circle with the markings that accept distances on the path. Then you can rotate or label so on as you wish.

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}  
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro\myradi{12/2/pi}
\draw[decoration={markings,
mark=at position 3cm with \coordinate (c3);,
mark=at position 7cm with \coordinate (c4);,
mark=at position 12cm with\coordinate(c5);% Redundant
}, postaction={decorate}] 
circle [radius=\myradi cm];
\draw (c3) -- (c4) --(c5) --cycle;
\end{tikzpicture}
\end{document}

enter image description here

6

Here is another variant (via TikZ) with a random starting angle (each compilation gives a different result):

enter image description here

enter image description here

\documentclass[tikz,margin=2mm]{standalone}
\usetikzlibrary{calc,positioning}
\pgfmathsetseed{\pdfuniformdeviate 10000000}
\begin{document}
\begin{tikzpicture}
  % constants
  \pgfmathsetmacro\unit{360/(3+4+5)}
  \pgfmathsetmacro\radius{2cm}
  \pgfmathsetmacro\labeldist{3mm}
  % random starting angle
  \pgfmathsetmacro\angleinit{rnd*360}
  % center
  \fill circle(2pt) coordinate (I);
  \node at ($(I) + (\angleinit:3mm)$) {I};
  % circle
  \draw circle(\radius pt);
  % triangle
  \draw ({\unit*0+\angleinit}:\radius pt) coordinate (A)
     -- ({\unit*(3)+\angleinit}:\radius pt) coordinate (B)
     -- ({\unit*(3+4)+\angleinit}:\radius pt) coordinate (C)
     -- cycle;
  % The vertices and their names
  \foreach \point in {A,B,C}{
    \fill (\point) circle (2pt);
    \node at ($(I)!\radius pt+\labeldist pt!(\point)$) {\point};
  }
  % the relative angular distances
  \node at ($(I)!\radius pt+\labeldist pt!($(A)!.5!(B)$)$) {3};
  \node at ($(I)!\radius pt+\labeldist pt!($(B)!.5!(C)$)$) {4};
  \node at ($(I)!\radius pt+\labeldist pt!($(C)!.5!(A)$)$) {5};
\end{tikzpicture}
\end{document}

Edit:

New version with labels formated in italic and segments IA, IB and IC.

enter image description here

\documentclass[tikz,margin=2mm]{standalone}
\usetikzlibrary{calc,positioning}
\pgfmathsetseed{\pdfuniformdeviate 10000000}
\begin{document}
\begin{tikzpicture}
  % constants
  \pgfmathsetmacro\unit{360/(3+4+5)}
  \pgfmathsetmacro\radius{2cm}
  \pgfmathsetmacro\labeldist{3mm}
  % random starting angle
  \pgfmathsetmacro\angleinit{rnd*360}
  % center
  \fill circle(2pt) coordinate (I);
  \node at ($(I) + (\angleinit+50:3mm)$) {$I$};
  % circle
  \draw circle(\radius pt);
  % triangle
  \draw ({\unit*0+\angleinit}:\radius pt) coordinate (A)
     -- ({\unit*(3)+\angleinit}:\radius pt) coordinate (B)
     -- ({\unit*(3+4)+\angleinit}:\radius pt) coordinate (C)
     -- cycle;
  % vertices, labels and segments
  \foreach \point in {A,B,C}{
    \fill (\point) circle (2pt);
    \node at ($(I)!\radius pt+\labeldist pt!(\point)$) {$\point$};
    \draw (I) -- (\point);
  }
  % relative angular distances
  \node at ($(I)!\radius pt+\labeldist pt!($(A)!.5!(B)$)$) {3};
  \node at ($(I)!\radius pt+\labeldist pt!($(B)!.5!(C)$)$) {4};
  \node at ($(I)!\radius pt+\labeldist pt!($(C)!.5!(A)$)$) {5};
\end{tikzpicture}
\end{document}

Last edit:

Examples with different polygons:

enter image description here

enter image description here

\documentclass[tikz,margin=2mm]{standalone}
\usetikzlibrary{calc,positioning}
\pgfmathsetseed{\pdfuniformdeviate 10000000}
\begin{document}
\foreach \p in {{A/1,B/2,C/4,D/5},{A/2,B/3,C/4,D/6,E/9}}{
  \begin{tikzpicture}
    \pgfmathsetmacro\r{2cm} \pgfmathsetmacro\ld{3mm}
    \foreach \l/\v[evaluate=\v as \s using \s + \v,remember=\s as \s (initially 0),
    remember=\l as \ls,remember=\v as \lv] in \p{}
    \pgfmathsetmacro\unit{360/\s} \pgfmathsetmacro\ai{rnd*360}
    \fill circle(2pt) coordinate (I); \draw circle(\r pt);
    \draw (\ai:\r pt)
    \foreach \l/\v[evaluate=\v as \s using \psum + \v, remember=\s as \psum (initially 0)]
    in \p {-- ({\unit*\psum+\ai}:\r pt) coordinate (\l)} -- cycle;
    \foreach \l/\v in \p {
      \draw (I) -- (\l); \fill (\l) circle (2pt);
      \node at ($(I)!\r pt+\ld pt!(\l)$) {$\l$};
    }
    \node[circle,inner sep=1pt,fill=white] at ($(I) + (\ai:5mm)$) {$I$};
    \foreach \l/\v[remember=\l as \pl (initially \ls),remember=\v as \pv (initially \lv)]
    in \p {\node at ($(I)!\r pt+\ld pt!($(\pl)!.5!(\l)$)$) {\pv};}
  \end{tikzpicture}
}
\end{document}
6
  • How can I format labels A, B, C and I italic? Apr 9, 2015 at 3:09
  • @minthao_2011 Replace {\point} by {$\point$} and {I} by {$I$}. Apr 9, 2015 at 7:12
  • Gabori please help me draw the segments IA, IB and IC. Apr 9, 2015 at 23:09
  • @minthao_2011 Add \draw (I) -- (B);... Apr 9, 2015 at 23:19
  • Please write for me a automatic code so that when I change number of arcs. For example, four arcs of lengths 1, 2, 4, 5 or five arcs of lengths 2, 3, 4, 6, 9. Thank you very much. I repaired your code in case four arcs of lengths 1, 2, 4, 5. Apr 13, 2015 at 2:24
5

As an alternative, here's some nice code for you in Metapost:

prologues := 3;
outputtemplate := "%j%c.eps";
beginfig(1);
for i=0 upto 11: z[i] = 60 right rotated 30i; endfor 
draw for i=0 upto 11: z[i] .. endfor cycle withcolor .67 red;
draw z0--z3--z7--cycle;
label.rt (btex $A$ etex, z0);
label.top(btex $B$ etex, z3);
label.lft(btex $C$ etex, z7);
dotlabel.top(btex $I$ etex, origin);
for i=0 upto 11: draw z[i] withpen pencircle scaled 3; endfor
endfig;end.

enter image description here

3

And here's a solution in Asymptote.

unitsize(1cm);
real L1 = 3.0;
real L2 = 4.0;
real L3 = 5.0;
real diameter = (L1 + L2 + L3) / pi;
path circle = scale(diameter/2)*unitcircle;
pair A = arcpoint(circle,0.0);
pair B = arcpoint(circle,L1);
pair C = arcpoint(circle,L1 + L2);
draw(circle, blue);
draw(A--B--C--cycle, red);
dot(Label("$A$"), A, dir(A));
dot(Label("$B$"), B, dir(B));
dot(Label("$C$"), C, dir(C));
pair L1mid = arcpoint(circle,L1/2.0);
pair L2mid = arcpoint(circle,L1+L2/2.0);
pair L3mid = arcpoint(circle,L1+L2+L3/2.0);
label(string(L1), L1mid, dir(L1mid));
label(string(L2), L2mid, dir(L2mid));
label(string(L3), L3mid, dir(L3mid));

enter image description here

3

This time with the mfpic package. At the basis, the same idea as proposed by Herbert and Thruston. Not the same implementation of course.

\documentclass{scrartcl}
\usepackage[metapost, mplabels, truebbox]{mfpic}
\mfpverbtex{%&latex
  \documentclass{scrartcl}
  \begin{document}}
\setlength{\mfpicunit}{1cm}
\opengraphsfile{\jobname}
\begin{document}
  \begin{mfpic}{0}{1}{0}{1}
      \draw[red]\circle{origin, 3}
      \fdef{r}{t}{3dir(90-30t)}
      \mfpfor{t = 0 upto 11}\point[3bp]{r(t)}\endmfpfor
      \polygon{r(0), r(3), r(7)}
      \tlpointsep{3bp}
      \tlabels{[bc]{r(0)}{$A$} [cl]{r(3)}{$B$} [tr]{r(7)}{$C$}}
  \end{mfpic}
  \closegraphsfile
\end{document}

To be processed in three steps: LaTeX, MetaPost, and LaTeX again.

enter image description here

You must log in to answer this question.

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