\section{Random point definition}
%<--------------------------------------------------------------------------->
%           points random
%<--------------------------------------------------------------------------->
At the moment there are four possibilities:
\begin{enumerate}
  \item point in a rectangle;
  \item on a segment;
  \item on a straight line;
  \item on a circle.
\end{enumerate}

\subsection{Obtaining random points}
This is the new version that replaces  \tkzcname{tkzGetRandPointOn}.
\begin{NewMacroBox}{tkzDefRandPointOn}{\oarg{local options}}%
{The result is a point with a random position that can be named with the macro \tkzcname{tkzGetPoint}. It is possible to use \tkzname{tkzPointResult} if it is not necessary to retain the results.}

\medskip
\begin{tabular}{lll}%
\toprule
options             & default & definition                         \\ 
\midrule
\TOline{rectangle=pt1 and pt2}  {}{[rectangle=A and B]} 
\TOline{segment= pt1--pt2} {}{[segment=A--B]}
\TOline{line=pt1--pt2}{}{[line=A--B]} 
\TOline{circle =center pt1 radius dim}{}{[circle = center A radius 2 cm]} 
\TOline{circle through=center pt1 through pt2}{}{[circle through= center A through B]}
\TOline{disk through=center pt1 through pt2}{}{[disk through=center A through B]}
\end{tabular}
\end{NewMacroBox} 

\subsection{Random point in a rectangle} 

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
  \tkzInit[xmax=5,ymax=5]\tkzGrid
  \tkzDefPoints{0/0/A,2/2/B,5/5/C}
  \tkzDefRandPointOn[rectangle = A and B]
  \tkzGetPoint{a}
  \tkzDefRandPointOn[rectangle = B and C]
  \tkzGetPoint{d}
  \tkzDrawLine(a,d)
  \tkzDrawPoints(A,B,C,a,d) 
  \tkzLabelPoints(A,B,C,a,d)  
\end{tikzpicture} 
\end{tkzexample} 

\subsection{Random point on a segment}  
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}  
  \tkzInit[xmax=5,ymax=5] \tkzGrid 
  \tkzDefPoints{0/0/A,2/2/B,3/3/C,5/5/D}  
  \tkzDefRandPointOn[segment = A--B]\tkzGetPoint{a}
  \tkzDefRandPointOn[segment = C--D]\tkzGetPoint{d}
  \tkzDrawPoints(A,B,C,D,a,d) 
  \tkzLabelPoints(A,B,C,D,a,d)
\end{tikzpicture}
\end{tkzexample}

\subsection{Random point on a straight line}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
  \tkzInit[xmax=5,ymax=5] \tkzGrid
  \tkzDefPoints{0/0/A,2/2/B,3/3/C,5/5/D}  
  \tkzDefRandPointOn[line = A--B]\tkzGetPoint{E}
  \tkzDefRandPointOn[line = C--D]\tkzGetPoint{F}
  \tkzDrawPoints(A,...,F)
  \tkzLabelPoints(A,...,F)
\end{tikzpicture}
\end{tkzexample}


\subsubsection{Example of random points}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
 \tkzDefPoints{0/0/A,2/2/B,-1/-1/C}
 \tkzDefCircle[through=](A,C) 
 \tkzGetLength{rAC}
 \tkzDrawCircle(A,C)
 \tkzDrawCircle(A,B)
 \tkzDefRandPointOn[rectangle=A and B]
 \tkzGetPoint{a}
 \tkzDefRandPointOn[segment=A--B]
 \tkzGetPoint{b}
 \tkzDefRandPointOn[circle=center A radius \rAC pt]
    \tkzGetPoint{d}
 \tkzDefRandPointOn[circle through= center A through B]
     \tkzGetPoint{c}
 \tkzDefRandPointOn[disk through=center A through B]
     \tkzGetPoint{e}
 \tkzLabelPoints[above right=3pt](A,B,C,a,b,...,e)
 \tkzDrawPoints[](A,B,C,a,b,...,e)
 \tkzDrawRectangle(A,B)
\end{tikzpicture}
\end{tkzexample}

\subsection{Random point on a circle}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture} 
  \tkzInit[xmax=5,ymax=5]  \tkzGrid   
  \tkzDefPoints{3/2/A,1/1/B}
  \tkzCalcLength[cm](A,B) \tkzGetLength{rAB}
  \tkzDrawCircle[R](A,\rAB cm) 
  \tkzDefRandPointOn[circle = center A radius
   \rAB cm]\tkzGetPoint{a}
  \tkzDrawSegment(A,a)
  \tkzDrawPoints(A,B,a) 
  \tkzLabelPoints(A,B,a)  
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Random example and circle of Apollonius}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[scale=1]
 \tkzDefPoints{0/0/A,3/0/B}
 \def\coeffK{2}
 \tkzApolloniusCenter[K=\coeffK](A,B) 
 \tkzGetPoint{P}
 \tkzDefApolloniusPoint[K=\coeffK](A,B) 
 \tkzGetPoint{M}
 \tkzDefApolloniusRadius[K=\coeffK](A,B)
 \tkzDrawCircle[R,color = blue!50!black,
     fill=blue!20,
     opacity=.4](tkzPointResult,\tkzLengthResult pt)
 \tkzDefRandPointOn[circle through= center P through M]
 \tkzGetPoint{N}
 \tkzDrawPoints(A,B,P,M,N)
 \tkzLabelPoints(A,B,P,M,N)
 \tkzDrawSegments[red](N,A N,B)
 \tkzDrawPoints(A,B)
 \tkzDrawSegments[red](A,B)
 \tkzLabelCircle[R,draw,fill=green!10,%
     text width=3cm,%
     text centered](P,\tkzLengthResult pt-20pt)(-120)%
  { $MA/MB=\coeffK$\\$NA/NB=\coeffK$}
\end{tikzpicture}
\end{tkzexample}



\subsection{Middle of a compass segment}
 To conclude this section, here is a more complex example. It involves determining the middle of a segment, using only a compass. 

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[scale=.75]
  \tkzDefPoint(0,0){A}
  \tkzDefRandPointOn[circle= center A radius 4cm]
  \tkzGetPoint{B}
  \tkzDrawPoints(A,B)
  \tkzDefPointBy[rotation= center A angle 180](B) 
  \tkzGetPoint{C}
  \tkzInterCC[R](A,4 cm)(B,4 cm)
  \tkzGetPoints{I}{I'}
  \tkzInterCC[R](A,4 cm)(I,4 cm)
  \tkzGetPoints{J}{B}
  \tkzInterCC(B,A)(C,B)
  \tkzGetPoints{D}{E}
  \tkzInterCC(D,B)(E,B)
  \tkzGetPoints{M}{M'}
  \tikzset{arc/.style={color=brown,style=dashed,delta=10}}
  \tkzDrawArc[arc](C,D)(E)
  \tkzDrawArc[arc](B,E)(D)
  \tkzDrawCircle[color=brown,line width=.2pt](A,B)
  \tkzDrawArc[arc](D,B)(M) 
  \tkzDrawArc[arc](E,M)(B)
  \tkzCompasss[color=red,style=solid](B,I I,J J,C)
  \tkzDrawPoints(B,C,D,E,M)
  \tkzLabelPoints(A,B,M)
 \end{tikzpicture}
 \end{tkzexample}
   
\endinput

 