\section{The Circles}

Among the following macros, one will allow you to draw a circle, which is not a real feat. To do this, you will need to know the center of the circle and either the radius of the circle or a point on the circumference. It seemed to me that the most frequent use was to draw a circle with a given centre passing through a given point. This will be the default method, otherwise you will have to use the \tkzname{R} option. There are a large number of special circles, for example the circle circumscribed by a triangle.

\begin{itemize}
  \item  I have created a first macro \tkzcname{tkzDefCircle} which allows, according to a particular circle, to retrieve its center and the measurement of the radius in cm. This recovery is done with the macros \tkzcname{tkzGetPoint} and \tkzcname{tkzGetLength};
 
 \item then a macro \tkzcname{tkzDrawCircle};
 
 \item then a macro that allows you to color in a disc, but without drawing the circle \tkzcname{tkzFillCircle};
 
 \item sometimes, it is necessary for a drawing to be contained in a disk, this is the role assigned to \tkzcname{tkzClipCircle};

 
 \item  it finally remains to be able to give a label to designate a circle and if several possibilities are offered, we will see here \tkzcname{tkzLabelCircle}.
\end{itemize} 

\subsection{Characteristics of a circle: \tkzcname{tkzDefCircle}}
 
This macro allows you to retrieve the characteristics (center and radius) of certain circles.

\begin{NewMacroBox}{tkzDefCircle}{\oarg{local options}\parg{A,B} or \parg{A,B,C}}%
\tkzHandBomb\ Attention the arguments are lists of two or three points. This macro is either used in partnership with \\ \tkzcname{tkzGetPoint} and/or \tkzcname{tkzGetLength} to obtain the center and the radius of the circle, or by using \\ \tkzname{tkzPointResult} and \tkzname{tkzLengthResult} if it is not necessary to keep the results.

\medskip
\begin{tabular}{lll}%
\toprule
arguments           & example & explication                         \\
\midrule
\TAline{\parg{pt1,pt2} or \parg{pt1,pt2,pt3}}{\parg{A,B}} {$[AB]$ is radius $A$ is the center}
\bottomrule
\end{tabular} 

\medskip
\begin{tabular}{lll}%
\toprule
options             & default & definition                         \\ 
\midrule
\TOline{through}      {through}{circle characterized by two points defining a radius} 
\TOline{diameter}     {through}{circle characterized by two points defining a diameter}
\TOline{circum}       {through}{circle circumscribed of a triangle} 
\TOline{in}           {through}{incircle a triangle} 
\TOline{ex}           {through}{excircle of a  triangle}
\TOline{euler or nine}{through}{Euler's Circle}
\TOline{spieker}      {through}{Spieker Circle}
\TOline{apollonius}   {through}{circle of Apollonius} 
\TOline{K} {1}{coefficient used for a circle of Apollonius} 
 \bottomrule
\end{tabular}

{In the following examples, I draw the circles with a macro not yet presented, but this is not necessary. In some cases you may only need the center or the radius.}
\end{NewMacroBox}  

 \subsubsection{Example with a random point and  option \tkzname{through}} 

\begin{tkzexample}[latex=7 cm,small]
\begin{tikzpicture}[scale=1]
  \tkzDefPoint(0,4){A}
  \tkzDefPoint(2,2){B}
  \tkzDefMidPoint(A,B) \tkzGetPoint{I}
  \tkzDefRandPointOn[segment = I--B]
  \tkzGetPoint{C}
  \tkzDefCircle[through](A,C) 
  \tkzGetLength{rACcm}
  \tkzcmtopt(\rACcm){rACpt}
  \tkzDrawCircle(A,C)
  \tkzDrawPoints(A,B,C)
  \tkzLabelPoints(A,B,C) 
  \tkzLabelCircle[draw,
           text width=3cm,text centered,
           font=\scriptsize,below=1cm](A,C)(-90)%
  {The radius measurement is:
   \rACcm cm i.e. \rACpt pt}  
\end{tikzpicture}   
 \end{tkzexample}  
 
 \subsubsection{Example with  option \tkzname{diameter}}  
 It is simpler here to search directly for the middle of $[AB]$.
 \begin{tkzexample}[latex=7cm,small]  
 \begin{tikzpicture}[scale=1]
    \tkzDefPoint(0,0){A} 
    \tkzDefPoint(2,2){B}
    \tkzDefCircle[diameter](A,B)  
    \tkzGetPoint{O}  
    \tkzDrawCircle(O,B) 
    \tkzDrawSegment(A,B)
    \tkzDrawPoints(A,B,O)   
    \tkzLabelPoints(A,B,O)
 \end{tikzpicture} 
 \end{tkzexample}    

 \subsubsection{Circles inscribed and circumscribed for a given triangle} 
 
\begin{tkzexample}[latex=7cm,small]  
\begin{tikzpicture}[scale=.75]
 \tkzDefPoint(2,2){A}  \tkzDefPoint(5,-2){B}
 \tkzDefPoint(1,-2){C}
 \tkzDefCircle[in](A,B,C)
 \tkzGetPoint{I}    \tkzGetLength{rIN}
 \tkzDefCircle[circum](A,B,C)
 \tkzGetPoint{K}   \tkzGetLength{rCI}   
 \tkzDrawCircles[R,new](I,{\rIN} K,{\rCI}) 
 \tkzLabelPoints[below](B,C)
 \tkzLabelPoints[above left](A,I,K)
 \tkzDrawPolygon(A,B,C)
 \tkzDrawPoints(A,B,C,I,K) 
\end{tikzpicture} 
\end{tkzexample}

 \subsubsection{Example with option \tkzname{ex}}
We want to define an excircle of a  triangle relatively to point $C$

\begin{tkzexample}[latex=8cm,small]
\begin{tikzpicture}[scale=.75]
  \tkzDefPoints{ 0/0/A,4/0/B,0.8/4/C}
  \tkzDefCircle[ex](B,C,A)                   
  \tkzGetPoint{J_c} \tkzGetLength{rc}
  \tkzDefPointBy[projection=onto A--C ](J_c)   
  \tkzGetPoint{X_c}
  \tkzDefPointBy[projection=onto A--B ](J_c)   
  \tkzGetPoint{Y_c}     
  \tkzDrawPolygon(A,B,C)
  \tkzDrawCircle[R,color=lightgray](J_c,\rc)
  % possible  \tkzDrawCircle[ex](A,B,C) 
  \tkzDrawCircle[in,new](A,B,C)    
  \tkzGetPoint{I} 
  \tkzDefPointBy[projection=onto A--C ](I)   
  \tkzGetPoint{F} 
  \tkzDefPointBy[projection=onto A--B ](I)   
  \tkzGetPoint{D}    
  \tkzDrawLines[add=0 and 2.2,dashed](C,A C,B)
  \tkzDrawSegments[dashed](J_c,X_c I,D  I,F%
          J_c,Y_c)
  \tkzMarkRightAngles(A,F,I B,D,I J_c,X_c,A%
         J_c,Y_c,B)
  \tkzDrawPoints(B,C,A,I,D,F,X_c,J_c,Y_c)
  \tkzLabelPoints(B,A,J_c,I,D,X_c,Y_c)
  \tkzLabelPoints[above left](C)
  \tkzLabelPoints[left](F)
\end{tikzpicture}    
\end{tkzexample}
  
 \subsubsection{Euler's circle for a given triangle with option \tkzname{euler}}
 
We verify that this circle passes through the middle of each side.
\begin{tkzexample}[latex=6cm,small]  
\begin{tikzpicture}[scale=.75]
   \tkzDefPoint(5,3.5){A} 
   \tkzDefPoint(0,0){B} \tkzDefPoint(7,0){C}
   \tkzDefCircle[euler](A,B,C)
   \tkzGetPoint{E}  \tkzGetLength{rEuler}
   \tkzDefSpcTriangle[medial](A,B,C){M_a,M_b,M_c}
   \tkzDrawPoints(A,B,C,E,M_a,M_b,M_c)    
   \tkzDrawCircle[R](E,\rEuler)
   \tkzDrawPolygon(A,B,C)    
   \tkzLabelPoints[below](B,C)  
   \tkzLabelPoints[left](A,E)   
\end{tikzpicture}
\end{tkzexample}

 \subsubsection{Apollonius circles for a given segment option \tkzname{apollonius}} 
 
\begin{tkzexample}[latex=9cm,small]    
\begin{tikzpicture}[scale=0.75]
  \tkzDefPoint(0,0){A} 
  \tkzDefPoint(4,0){B}
  \tkzDefCircle[apollonius,K=2](A,B)
  \tkzGetPoint{K1}
  \tkzGetLength{rAp}
  \tkzDrawCircle[R,color = teal!50!black,
      fill=teal!20,opacity=.4](K1,\rAp)
  \tkzDefCircle[apollonius,K=3](A,B)
  \tkzGetPoint{K2}   \tkzGetLength{rAp}
  \tkzDrawCircle[R,color=orange!50,
   fill=orange!20,opacity=.4](K2,\rAp) 
  \tkzLabelPoints[below](A,B,K1,K2)
  \tkzDrawPoints(A,B,K1,K2) 
  \tkzDrawLine[add=.2 and 1](A,B)  
\end{tikzpicture}
\end{tkzexample}  

 \subsubsection{Circles exinscribed to a given triangle option \tkzname{ex}}
 You can also get the center and the projection of it on one side of the triangle. 
 
 with \tkzcname{tkzGetFirstPoint\{Jb\}} and \tkzcname{tkzGetSecondPoint\{Tb\}}.
 
\begin{tkzexample}[latex=8cm,small]  
\begin{tikzpicture}[scale=.6]
  \tkzDefPoint(0,0){A}
  \tkzDefPoint(3,0){B}
  \tkzDefPoint(1,2.5){C}
  \tkzDefCircle[ex](A,B,C) \tkzGetPoint{I} 
    \tkzGetLength{rI}
  \tkzDefCircle[ex](C,A,B) \tkzGetPoint{J} 
    \tkzGetLength{rJ}
  \tkzDefCircle[ex](B,C,A) \tkzGetPoint{K} 
    \tkzGetLength{rK}
   \tkzDefCircle[in](B,C,A) \tkzGetPoint{O}
     \tkzGetLength{rO} 
  \tkzDrawLines[add=1.5 and 1.5](A,B A,C B,C)
  \tkzDrawPoints(I,J,K)
  \tkzDrawPolygon(A,B,C)
  \tkzDrawPolygon[dashed](I,J,K)
  \tkzDrawCircle[R,teal](O,\rO)
  \tkzDrawSegments[dashed](A,K B,J C,I)
  \tkzDrawPoints(A,B,C)
  \tkzDrawCircles[R,new](J,{\rJ} I,{\rI}%
                         K,{\rK})    
  \tkzLabelPoints(A,B,C,I,J,K)
\end{tikzpicture}
\end{tkzexample}
 
  \subsubsection{Spieker circle with option \tkzname{spieker}}   
The  incircle of the medial triangle $M_aM_bM_c$ is the Spieker circle:


\begin{tkzexample}[latex=6cm, small]
\begin{tikzpicture}[scale=1]
  \tkzDefPoints{ 0/0/A,4/0/B,0.8/4/C}
   \tkzDefSpcTriangle[medial](A,B,C){M_a,M_b,M_c}
   \tkzDefTriangleCenter[spieker](A,B,C) 
   \tkzGetPoint{S_p}
   \tkzDrawPolygon(A,B,C)
   \tkzDrawPolygon[cyan](M_a,M_b,M_c)
   \tkzDrawPoints(B,C,A)
   \tkzDrawPoints[new](M_a,M_b,M_c,S_p)
   \tkzDrawCircle[in,new](M_a,M_b,M_c)
   \tkzAutoLabelPoints[center=S_p,dist=.3](M_a,M_b,M_c)
   \tkzLabelPoints[right](S_p)
   \tkzAutoLabelPoints[center=S_p](A,B,C)
\end{tikzpicture}
\end{tkzexample}
 
 \subsubsection{Examples from js bibra tex.stackexchange.com}      

\begin{tikzpicture}[scale=0.4]
\tkzDefPoint(6,4){A}
\tkzDefPoint(6,-4){B}
\tkzDefMidPoint(B,A)\tkzGetPoint{P}
\tkzDefLine[orthogonal =through P](A,B)\tkzGetPoint{X}
\tkzDefCircle[through](X,P)
\tkzCalcLength(X,P)\tkzGetLength{rXP}
\tkzDefShiftPoint[X](180:\rXP*2){y}
\tkzDefPointWith[linear,K=0.3](y,P) \tkzGetPoint{x}
\tkzDrawPoints(X,x) 
\tkzDrawCircles(x,P X,P)
\tkzLabelLine[pos=0.5,above](x,P){r1}
\tkzDefShiftPoint[X](-60:\rXP){X'}
\tkzDrawSegments[<->, >=triangle 45](X,X' P,x)  
\tkzLabelLine[pos=0.5,above, sloped](X,X'){r}
\tkzLabelPoints[above](x)
\tkzLabelPoints[above](X)
\end{tikzpicture}

\begin{tkzexample}[code only, small]
\begin{tikzpicture}[scale=0.4]
\tkzDefPoint(6,4){A}
\tkzDefPoint(6,-4){B}
\tkzDefMidPoint(B,A)\tkzGetPoint{P}
\tkzDefLine[orthogonal =through P](A,B)
\tkzGetPoint{X}
\tkzDefCircle[through](X,P)
\tkzCalcLength(X,P)\tkzGetLength{rXP}
\tkzDefShiftPoint[X](180:\rXP*2){y}
\tkzDefPointWith[linear,K=0.3](y,P)
 \tkzGetPoint{x}
\tkzDrawPoints(X,x) 
\tkzDrawCircles(x,P X,P)
\tkzLabelLine[pos=0.5,above](x,P){r1}
\tkzDefShiftPoint[X](-60:\rXP){X'}
\tkzDrawSegments[<->, >=triangle 45](X,X' P,x)  
\tkzLabelLine[pos=0.5,above, sloped](X,X'){r}
\tkzLabelPoints[above](x)
\tkzLabelPoints[above](X)
\end{tikzpicture}
\end{tkzexample}

\begin{tikzpicture}
    \tkzDefPoint(0,4){A}
    \tkzDefPoint(2,2){B}
    \tkzDefMidPoint(B,A)\tkzGetPoint{P}
    \tkzDefLine[orthogonal =through P](B,A)
    \tkzGetPoint{X}
    \tkzDefCircle[through](X,P)
    \tkzGetLength{rXPpt}
    \tkzpttocm(\rXPpt){rXPcm}
    \tkzDefPointWith[linear,K=0.3](X,P) 
    \tkzGetPoint{x}
    \tkzDefCircle[through](x,P)
    \tkzGetLength{rxPpt}
    \tkzpttocm(\rxPpt){rxPcm}    
    \tkzDrawCircles(X,P x,P)
    \tkzDrawPoints(X,x)
    \tkzDrawSegment[<->, >=triangle 45](x,P)
    \tkzDrawSegment(P,X)
    \tkzLabelPoints(X,x)
    \tkzLabelLine[pos=0.5,left](x,P){r}
    \tkzCalcLength[cm](X,P)\tkzGetLength{rXP}
    \tkzDefShiftPoint[X](-90:\rXP){y}
    \tkzDrawSegments[<->, >=triangle 45](X,y)  
    \tkzLabelLine[pos=0.5,left](X,y){R}    
\end{tikzpicture}

\begin{tkzexample}[code only, small]
\begin{tikzpicture}
    \tkzDefPoint(0,4){A}
    \tkzDefPoint(2,2){B}
    \tkzDefMidPoint(B,A)\tkzGetPoint{P}
    \tkzDefLine[orthogonal =through P](B,A)
    \tkzGetPoint{X}
    \tkzDefCircle[through](X,P)
    \tkzGetLength{rXPpt}
    \tkzpttocm(\rXPpt){rXPcm}
    \tkzDefPointWith[linear,K=0.3](X,P) 
    \tkzGetPoint{x}
    \tkzDefCircle[through](x,P)
    \tkzGetLength{rxPpt}
    \tkzpttocm(\rxPpt){rxPcm}   
    \tkzDrawCircles(X,P x,P)
    \tkzDrawPoints(X,x)
    \tkzDrawSegment[<->, >=triangle 45](x,P)
    \tkzDrawSegment(P,X)
    \tkzLabelPoints(X,x)
    \tkzLabelLine[pos=0.5,left](x,P){r}
    \tkzCalcLength[cm](X,P)\tkzGetLength{rXP}
    \tkzDefShiftPoint[X](-90:\rXP){y}
    \tkzDrawSegments[<->, >=triangle 45](X,y)  
    \tkzLabelLine[pos=0.5,left](X,y){R}    
\end{tikzpicture}
\end{tkzexample}
\endinput