1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
\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]}
\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}
\subsubsection{Random point in a rectangle}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
\tkzDefPoints{0/0/A,5/3/C}
\tkzDefRandPointOn[rectangle = A and C]
\tkzGetPoint{E}
\tkzDefRectangle(A,C)\tkzGetPoints{B}{D}
\tkzDrawPolygon[red](A,...,D)
\tkzDrawPoints(A,...,E)
\tkzLabelPoints(A,B)
\tkzLabelPoints[above](C,D,E)
\end{tikzpicture}
\end{tkzexample}
\subsubsection{Random point on a segment or a line}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
\tkzDefPoints{0/0/A,5/2/C}
\tkzDefRandPointOn[segment = A--C]\tkzGetPoint{B}
\tkzDrawLine(A,C)
\tkzDrawPoints(A,C) \tkzDrawPoint[red](B)
\tkzLabelPoints(A,C) \tkzLabelPoints[red](B)
\end{tikzpicture}
\end{tkzexample}
\subsubsection{Random point on a circle or a disk}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
\tkzDefPoints{3/2/A,1/1/B}
\tkzCalcLength(A,B) \tkzGetLength{rAB}
\tkzDefRandPointOn[circle = center A radius \rAB]
\tkzGetPoint{C}
\tkzDefRandPointOn[circle through= center A through B]
\tkzGetPoint{D}
\tkzDefRandPointOn[disk through=center A through B]
\tkzGetPoint{E}
\tkzDrawCircle(A,B)
\tkzDrawPoints(A,B)
\tkzLabelPoints(A,B)
\tkzDrawPoints[red](C,D,E)
\tkzLabelPoints[red,right](C,D,E)
\end{tikzpicture}
\end{tkzexample}
\endinput
|