I tried to fill a circular segment but I'm having trouble doing it. Here's my MWE:

\documentclass[10pt]{scrartcl}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{calc,backgrounds}
\usetkzobj{all}
\begin{document}

\begin{tikzpicture}
\tkzDefPoints{0/0/C, 4/0/B}
\tkzDrawTriangle[pythagore](C,B)
\tkzGetPoint{A}
\tkzDefCircle[circum](A,B,C)
\tkzGetPoint{O}
\tkzGetLength{cr}
\tkzDrawCircle[R](O,\cr pt)
\tkzDrawPoints(O)
\tkzLabelPoints[left](A)
\tkzLabelPoints[right](C)
\tkzLabelPoints[above left](B)
\tkzLabelPoints[below](O)
\tkzLabelSegment[above left](A,B){\Large 6 cm}
\tkzLabelSegment[above right](B,C){\Large 8 cm}
\begin{scope}[fill=gray, opacity=0.5]
\fill[clip] (B) -- (A) arc (90:-90:1.5cm) -- cycle;
\end{scope}
\end{tikzpicture}

\end{document}

enter image description here

I'll rotate the picture by 143 degrees.

  • I added \usetkzobj{all} to make your code compile. – marmot Sep 24 at 21:12
  • Oops, forgot. Thanks! – Mark Fantini Sep 24 at 21:14

Really easy with the calc library. Perhaps even easier with tkz-euclide if you speak French, which I don't.

\documentclass[10pt]{scrartcl}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{calc,backgrounds}
\usetkzobj{all}
\begin{document}

\begin{tikzpicture}
\tkzDefPoints{0/0/C, 4/0/B}
\tkzDrawTriangle[pythagore](C,B)
\tkzGetPoint{A}
\tkzDefCircle[circum](A,B,C)
\tkzGetPoint{O}
\tkzGetLength{cr}
\tkzDrawCircle[R](O,\cr pt)
\tkzDrawPoints(O)
\tkzLabelPoints[left](A)
\tkzLabelPoints[right](C)
\tkzLabelPoints[above left](B)
\tkzLabelPoints[below](O)
\tkzLabelSegment[above left](A,B){\Large 6 cm}
\tkzLabelSegment[above right](B,C){\Large 8 cm}
\begin{scope}[fill=gray, opacity=0.5]
\fill let \p1=($(A)-(O)$),\p2=($(B)-(O)$),
\n1={atan2(\y1,\x1)},\n2={atan2(\y2,\x2)},\n3={veclen(\x1,\y1)} in 
(B) -- (A) arc (\n1:\n2:\n3) -- cycle;
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Explanation: \p1=($(A)-(O)$) means that the coordinates of \p1, \x1 and \y1 will be the x- and y-coordinates of the vector O-A, likewise for \p2 and B. Correspondingly, \n1 and \n2 will be the angles of A and B, respectively, and \n3 the radius of the circle. These are the quantities needed to draw the arc.

  • P.S. You can rotate the picture, of course, by saying \begin{tikzpicture}[rotate=143]. You can even compute the exact rotation angle by saying \path let \p1=($(A)-(O)$),\n1={180-atan2(\y1,\x1)} in \pgfextra{\typeout{\n1}};, after which you may decide to use \begin{tikzpicture}[rotate=143.13011]. ;-) – marmot Sep 24 at 23:33

Also available in Metapost; here wrapped up in luamplib, so please compile with lualatex.

enter image description here

[I hope that I have correctly interpreted the OP "rotate the picture by 143 degrees".]

\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
    path o; 
    o = fullcircle scaled 10 cm;

    % "time" around the circle, 360° = 8 points
    numeric a, b, c;
    c = 0;                 % = 0°
    b = 2/45 angle (3,4);  % = 106.26°
    a = 4;                 % = 180°

    pair A, B, C;
    C = point c of o;
    B = point b of o;
    A = point a of o;

    fill subpath (b,a) of o -- cycle withcolor 3/4 white;

    draw o;
    draw A--B--C--cycle;

    dotlabel.lft("$A$", A);
    dotlabel.top("$B$", B);
    dotlabel.rt ("$C$", C);
    dotlabel.bot("$O$", origin);

    label.lrt (decimal round(abs(A-B)/cm) & "\thinspace cm", 1/2[A,B]);
    label.llft(decimal round(abs(B-C)/cm) & "\thinspace cm", 1/2[B,C]);

endfig;
\end{mplibcode}
\end{document}
  • You interpreted correct. Thank you! – Mark Fantini Sep 24 at 23:21

It is simply a calculation error of half the angle AOB which measures arcsin(3/5) or about 36.8699 degrees with a radius of 2.5 cm.

This give:

\fill[clip] (B) -- (A) arc (36.8699:-36.8699:2.5cm) -- cycle;

Full code:

\documentclass[10pt]{scrartcl}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{calc,backgrounds}
\usetkzobj{all}
\begin{document}

\begin{tikzpicture}
\tkzDefPoints{0/0/C, 4/0/B}
\tkzDrawTriangle[pythagore](C,B)
\tkzGetPoint{A}
\tkzDefCircle[circum](A,B,C)
\tkzGetPoint{O}
\tkzGetLength{cr}
\tkzDrawCircle[R](O,\cr pt)
\tkzDrawPoints(O)
\tkzLabelPoints[left](A)
\tkzLabelPoints[right](C)
\tkzLabelPoints[above left](B)
\tkzLabelPoints[below](O)
\tkzLabelSegment[above left](A,B){\Large 6 cm}
\tkzLabelSegment[above right](B,C){\Large 8 cm}
\draw[fill=gray!50] (B) -- (A) arc (asin(3/5:-asin(3/5):2.5cm) -- cycle;
\end{tikzpicture}

\end{document}

fill-rect-trian

  • 1
    @marmot Yes, indeed, we can make these calculations by pgf. I never use and certainly mistakenly the computing capabilities of pgf.. You are right clip is useless, on the other hand it is necessary to make draw because otherwise the segment is not plotted. I edited my answers. I upvoted some time ago too on your answer :) – AndréC Sep 25 at 4:33
  • @marmot, I noticed that for some time now, you've been deleting your comments. It is not a good idea, reading the comments from the beginning often helps to understand the evolution of an answer. Moreover, this makes the other comments incomprehensible. :( – AndréC Sep 25 at 5:29

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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