It's an easy TikZ question for people who use it. I tried reading the TikZ manual p. 112 several times but it seems too complicated on the filling part, all the infinity and whatnot... So I currently have this code:

\documentclass[letterpaper,12pt]{exam}
\usepackage{pgfplots}
\begin{document}

\begin{center}
\begin{tikzpicture}
\draw (0,0) -- (9.2106,4.228) -- (10.857,0) -- (9.2106,-4.228) -- cycle (9.2106,-4.228) arc (-22.5:22.5:11cm)
node [left] at (0,0) {$O$}
node [above] at (9.2106,4.228) {$A$}
node [below] at (9.2106,-4.228) {$B$}
node [right] at (10.857,0) {$P$};
\end{tikzpicture}

\begin{tikzpicture}
\draw (-3,0) -- (3,0);
\draw (3,0) arc (0:180:3cm);
\draw (2.5980762,1.5) -- (-2.12132,2.121320)
node [yshift=-2pt,below] at (0,0) {$O$}
node [xshift=-2pt,left] at (-3,0) {$A$}
node [xshift=-2pt,left] at (-2.12132,2.121320) {$B$}
node [xshift=2pt,right] at (2.5980762,1.5) {$C$}
node [xshift=2pt,right] at (3,0) {$D$};
\end{tikzpicture}
\end{center}
\end{document}


And what it produces is these 2 pictures, without the shading. I need to shade the areas shaded in this picture and add the 0.8 rad but as you see, the node isn't working for some reason. Here's a slightly different solution using intersection segments (you actually need pgfplots for this), and the tkz-euclide package for the angle.

Since you mentioned shading, I applied some shading. I had to re-create some paths such as the arc A-B, since it was not "perfect". Basically the arc didn't actually reach the coordinate A: So I used the command <coordinate> to[bend right=20] <coordinate> which, except for minor (negligible) differences, described the same arc.

## Output ## Code

\documentclass[letterpaper,12pt]{exam}
\usepackage{pgfplots}
\usepackage{tikz,tkz-euclide}
\usetkzobj{all}

\usetikzlibrary{fillbetween,backgrounds}

\begin{document}
\begin{center}
\begin{tikzpicture}
\draw (0,0) -- (9.2106,4.228) -- (10.857,0) -- (9.2106,-4.228) -- cycle (9.2106,-4.228) to[bend right=20] (9.2106,4.228)
node [left] at (0,0) {$O$}
node [above] at (9.2106,4.228) {$A$}
node [below] at (9.2106,-4.228) {$B$}
node [right] at (10.857,0) {$P$};

\filldraw[draw=black,bottom color=black, top color=white] (9.2106,4.228) -- (10.857,0) -- (9.2106,-4.228) to[bend right=20] (9.2106,4.228);

\coordinate (O) at (0,0);
\coordinate (A) at (9.2106,4.228);
\coordinate (B) at (9.2106,-4.228);
\tkzFindAngle(B,O,A)
\tkzMarkAngle[draw=black,size=2.5](B,O,A)
\end{tikzpicture}
\begin{tikzpicture}
\draw (-3,0) -- (3,0);
\draw[name path=curve] (3,0) arc (0:180:3cm);
\draw (2.5980762,1.5) -- (-2.12132,2.121320)
node [yshift=-2pt,below] at (0,0) {$O$}
node [xshift=-2pt,left] at (-3,0) {$A$}
node [xshift=-2pt,left] at (-2.12132,2.121320) {$B$}
node [xshift=2pt,right] at (2.5980762,1.5) {$C$}
node [xshift=2pt,right] at (3,0) {$D$};

\begin{scope}[on background layer]
\path[name path=line1] (2.5980762,1.5) -- (-2.13132,2.121320);
\path[name path=myarc,intersection segments={of=line1 and curve}];
\filldraw[draw=black,bottom color=black, top color=white]
[intersection segments={of=line1 and myarc}];
\end{scope}
\end{tikzpicture}
\end{center}
\end{document}


## Some colour!

Replace the shade colours with bottom color=blue!50!black, top color=cyan!50 • Wow that's so pretty. I wonder why the "0.8 rad" works for you but not for me. :S – Zack Fair May 28 '15 at 9:34
• @FahimAbdullah This code doesn't work in your document? – Alenanno May 28 '15 at 10:37
• Yeah it works very well. I was jut referring to the node at (2,1) {0.8 rad}; in my code but it seems you made a different piece of code to add the angle rather than this. But why doesn't it work? It's supposed to, since it's a node with some text, right? – Zack Fair May 28 '15 at 11:34
• @FahimAbdullah Try \node[anchor=west] at (.5,0) {0.8 rad}; – Alenanno May 28 '15 at 11:55
• Oh thanks that works (without the ). Although I will stick to your one with the angle marker. It's much prettier. :) – Zack Fair May 28 '15 at 12:53

You just need to delimit the areas. For the first case it's easy, but the second one is trickier. In this case the whole semicircle is filled but previous clip command defines which area will be preserved and which one eliminated. Both fill has been drawn on the background layer, this way previously drawn lines appear on top.

\documentclass[letterpaper,12pt]{exam}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\begin{document}

\begin{center}
\begin{tikzpicture}
\draw (0,0) -- (9.2106,4.228) -- (10.857,0) -- (9.2106,-4.228) -- cycle (9.2106,-4.228) arc (-22.5:22.5:11cm)
node [left] at (0,0) {$O$}
node [above] at (9.2106,4.228) {$A$}
node [below] at (9.2106,-4.228) {$B$}
node [right] at (10.857,0) {$P$};

\begin{scope}[on background layer]
\fill[gray] (9.2106,4.228) arc (22.5:-22.5:11cm) -- (10.857,0) -- cycle;
\end{scope}

\draw (22.5:2.5cm) arc (22.5:-22.5:2.5) node[midway,left] {0.8 rad};
\end{tikzpicture}

\begin{tikzpicture}
\draw (-3,0) -- (3,0);
\draw (3,0) arc (0:180:3cm);
\draw (2.5980762,1.5) -- (-2.12132,2.121320)
node [yshift=-2pt,below] at (0,0) {$O$}
node [xshift=-2pt,left] at (-3,0) {$A$}
node [xshift=-2pt,left] at (-2.12132,2.121320) {$B$}
node [xshift=2pt,right] at (2.5980762,1.5) {$C$}
node [xshift=2pt,right] at (3,0) {$D$};

\begin{scope}[on background layer]
\clip (-2.12132,2.121320) --++(90:2cm) -| (2.5980762,1.5)--cycle;
\fill[gray] (3,0) arc (0:180:3cm)--cycle;
\end{scope}
\end{tikzpicture}
\end{center}
\end{document} There's nothing about your example that requires pgfplots. You only need tikz. Nevertheless I've kept your preamble.

\documentclass[letterpaper,12pt]{exam}
\usepackage{pgfplots}
\begin{document}

\begin{center}
\begin{tikzpicture}
\path
(0,0)           coordinate (O)
(9.2106,4.228)  coordinate (A)
(9.2106,-4.228) coordinate (B)
(10.857,0)      coordinate (P);
\draw   (O) --
(A) --
(P) --
(B) --
cycle
(B) arc (-22.5:22.5:11cm);
\path
node [left]  at (O) {$O$}
node [above] at (A) {$A$}
node [below] at (B) {$B$}
node [right] at (P) {$P$};

\fill (B) arc (-22.5:22.5:11cm) -- (P) -- cycle;
\end{tikzpicture}

\begin{tikzpicture}
\path
coordinate (O) at (0,0)
coordinate (A) at (-3,0)
coordinate (B) at (-2.12132,2.121320)
coordinate (C) at (2.5980762,1.5)
coordinate (D) at (3,0)               ;

\draw (A) -- (D);
\draw (D) arc (0:180:3cm);
\draw (C) -- (B);
\fill (O) circle [radius=2pt] node [yshift=-2pt,below] {$O$}
(D) circle [radius=2pt] node [xshift=2pt,right]  {$D$}
(A) circle [radius=2pt] node [xshift=-2pt,left]  {$A$}
(B) circle [radius=2pt] node [xshift=-2pt,left]  {$B$}
(C) circle [radius=2pt] node [xshift=2pt,right]  {$C$}
;
\pgfmathanglebetweenpoints{\pgfpointanchor{O}{center}}
{\pgfpointanchor{C}{center}}
\edef\aeAngOC{\pgfmathresult}
\pgfmathanglebetweenpoints{\pgfpointanchor{O}{center}}
{\pgfpointanchor{B}{center}}
\edef\aeAngOB{\pgfmathresult}

\fill (B) -- (C) arc (\aeAngOC:\aeAngOB:3cm);

\end{tikzpicture}
\end{center}
\end{document} To facilitate things, I've named the coordinates.

The first picture is easy enough to create and I'll leave my code for it unexplained.

For the second picture a bit more work needs to be done. I need just the portion of the arc above the chord. To create only that portion of the arc, I find the angles along OC and OB. This is done with the command:

\pgfmathanglebetweenpoints{<point>}{<point>}


But pgf does not expect coordinate or node names, to get around this I use the macro

\pgfpointanchor{<coordinate name>}{center}


\pgfmathanglebetweenpoints doesn't return a value; it saves the calculated angle to \pgfmathresult. I need to save this value before I do anything else with TikZ. (TikZ uses this macro all over the place in many, many of its path calculations etc.) To extract the value of \pgfmathresult I use

\edef<command sequence>{\pgfmathresult}


Using \edef here is important because you want the value of \pgfmathresult at the time of the definition.

• Thanks so much. I used pgfplot so it loads anything else I might need from TikZ like the library stuff and all. Ofcourse I could load only TikZ and then anything else separately but I guess this is more compact. – Zack Fair May 27 '15 at 22:01