summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/tkz-euclide/TKZdoc-euclide-rnd.tex
blob: 9427fd8da31ebc01c47721f71dc6080d9e687e48 (plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
\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} 

\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{Random point on a circle}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
\tkzInit[ymin=-1,xmax=6,ymax=5] \tkzGrid 
\tkzDefPoints{3/2/A,1/1/B}
\tkzCalcLength(A,B) \tkzGetLength{rAB} 
\tkzDefRandPointOn[circle = center A radius \rAB] 
\tkzGetPoint{a}
\tkzDefRandPointOn[circle through= center A through B]
\tkzGetPoint{b}
\tkzDefRandPointOn[disk through=center A through B]
\tkzGetPoint{c}
\tkzDrawCircle[R](A,\rAB)
\tkzDrawSegment(A,a)
\tkzDrawPoints(A,B,a,b,c)
\tkzLabelPoints(A,B,a,b,c)
\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}
 \tkzDefRandPointOn[circle through=%
                center P through M]
 \tkzGetPoint{N}
 \tkzDefApolloniusRadius[K=\coeffK](A,B)
 \tkzDrawCircle[R,color = blue!50!black,
     fill=blue!20,
     opacity=.4](tkzPointResult,\tkzLengthResult)
 \tkzLabelCircle[R,draw,fill=green!10,%
     text width=3cm,%
     text centered](P,\tkzLengthResult+1)(-120)%
  { $MA/MB=\coeffK$\\$NA/NB=\coeffK$}
 \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)
\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{tikzpicture}
  \tkzDefPoint(0,0){A}
  \tkzDefRandPointOn[circle= center A radius 4]
  \tkzGetPoint{B}
  \tkzDefPointBy[rotation= center A angle 180](B) 
  \tkzGetPoint{C}
  \tkzInterCC[R](A,4)(B,4)
  \tkzGetPoints{I}{I'}
  \tkzInterCC[R](A,4)(I,4)
  \tkzGetPoints{J}{B}
  \tkzInterCC(B,A)(C,B)
  \tkzGetPoints{D}{E}
  \tkzInterCC(D,B)(E,B)
  \tkzGetPoints{M}{M'}
  \tkzSetUpArc[color=teal,style=dashed,delta=10]
  \tkzDrawArc(C,D)(E)
  \tkzDrawArc(B,E)(D)
  \tkzDrawCircle[color=teal,line width=.2pt](A,B)
  \tkzDrawArc(D,B)(M) 
  \tkzDrawArc(E,M)(B)
  \tkzCompasss[style=solid](B,I I,J J,C)
  \tkzDrawPoints(A,B,C,D,E,M)
  \tkzLabelPoints(A,B,M)
 \end{tikzpicture}
 
\begin{tkzexample}[code only,small]
\begin{tikzpicture}
  \tkzDefPoint(0,0){A}
  \tkzDefRandPointOn[circle= center A radius 4]
  \tkzGetPoint{B}
  \tkzDefPointBy[rotation= center A angle 180](B) 
  \tkzGetPoint{C}
  \tkzInterCC[R](A,4)(B,4)
  \tkzGetPoints{I}{I'}
  \tkzInterCC[R](A,4)(I,4)
  \tkzGetPoints{J}{B}
  \tkzInterCC(B,A)(C,B)
  \tkzGetPoints{D}{E}
  \tkzInterCC(D,B)(E,B)
  \tkzGetPoints{M}{M'}
  \tkzSetUpArc[ccolor=teal,style=dashed,delta=10]
  \tkzDrawArc(C,D)(E)
  \tkzDrawArc(B,E)(D)
  \tkzDrawCircle[color=teal,line width=.2pt](A,B)
  \tkzDrawArc(D,B)(M) 
  \tkzDrawArc(E,M)(B)
  \tkzCompasss[color=orange,style=solid](B,I I,J J,C)
  \tkzDrawPoints(A,B,C,D,E,M)
  \tkzLabelPoints(A,B,M)
 \end{tikzpicture}
 \end{tkzexample}
   
\endinput