Debian Codegraph @

texmf-dist/doc/latex/tkz-euclide/TKZdoc-euclide-rnd.tex

raw
1 \section{Random point definition}
2 %<--------------------------------------------------------------------------->
3 % points random
4 %<--------------------------------------------------------------------------->
5 At the moment there are four possibilities:
6 \begin{enumerate}
7 \item point in a rectangle;
8 \item on a segment;
9 \item on a straight line;
10 \item on a circle.
11 \end{enumerate}
12
13 \subsection{Obtaining random points}
14 This is the new version that replaces \tkzcname{tkzGetRandPointOn}.
15 \begin{NewMacroBox}{tkzDefRandPointOn}{\oarg{local options}}%
16 {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.}
17
18 \medskip
19 \begin{tabular}{lll}%
20 \toprule
21 options & default & definition \\
22 \midrule
23 \TOline{rectangle=pt1 and pt2} {}{[rectangle=A and B]}
24 \TOline{segment= pt1--pt2} {}{[segment=A--B]}
25 \TOline{line=pt1--pt2}{}{[line=A--B]}
26 \TOline{circle =center pt1 radius dim}{}{[circle = center A radius 2]}
27 \TOline{circle through=center pt1 through pt2}{}{[circle through= center A through B]}
28 \TOline{disk through=center pt1 through pt2}{}{[disk through=center A through B]}
29 \end{tabular}
30 \end{NewMacroBox}
31
32 \subsubsection{Random point in a rectangle}
33
34 \begin{tkzexample}[latex=7cm,small]
35 \begin{tikzpicture}
36 \tkzDefPoints{0/0/A,5/3/C}
37 \tkzDefRandPointOn[rectangle = A and C]
38 \tkzGetPoint{E}
39 \tkzDefRectangle(A,C)\tkzGetPoints{B}{D}
40 \tkzDrawPolygon[red](A,...,D)
41 \tkzDrawPoints(A,...,E)
42 \tkzLabelPoints(A,B)
43 \tkzLabelPoints[above](C,D,E)
44 \end{tikzpicture}
45 \end{tkzexample}
46
47 \subsubsection{Random point on a segment or a line}
48 \begin{tkzexample}[latex=7cm,small]
49 \begin{tikzpicture}
50 \tkzDefPoints{0/0/A,5/2/C}
51 \tkzDefRandPointOn[segment = A--C]\tkzGetPoint{B}
52 \tkzDrawLine(A,C)
53 \tkzDrawPoints(A,C) \tkzDrawPoint[red](B)
54 \tkzLabelPoints(A,C) \tkzLabelPoints[red](B)
55 \end{tikzpicture}
56 \end{tkzexample}
57
58
59 \subsubsection{Random point on a circle or a disk}
60 \begin{tkzexample}[latex=7cm,small]
61 \begin{tikzpicture}
62 \tkzDefPoints{3/2/A,1/1/B}
63 \tkzCalcLength(A,B) \tkzGetLength{rAB}
64 \tkzDefRandPointOn[circle = center A radius \rAB]
65 \tkzGetPoint{C}
66 \tkzDefRandPointOn[circle through= center A through B]
67 \tkzGetPoint{D}
68 \tkzDefRandPointOn[disk through=center A through B]
69 \tkzGetPoint{E}
70 \tkzDrawCircle(A,B)
71 \tkzDrawPoints(A,B)
72 \tkzLabelPoints(A,B)
73 \tkzDrawPoints[red](C,D,E)
74 \tkzLabelPoints[red,right](C,D,E)
75 \end{tikzpicture}
76 \end{tkzexample}
77
78 \endinput